Skip to content

To develop a REST API for an NFT marketplace, you can use Node.js for the backend server and MongoDB as the database. This API will facilitate various operations related to NFTs, such as creating, listing, buying, and transferring non-fungible tokens on the marketplace.

Notifications You must be signed in to change notification settings

jitendragangwar123/Rest-API-For-NFTs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rest-API-For-NFT

To build the Rest-API for NFT Marketplace using NodeJs and MongoDB.

$ npm init 
$ npm i express@4 
$ sudo npm install -g nodemon 
* JSON.parse() method used to convert the json file to object
* get status: 200 (OK)
* post status: 201 (created)
* Error status: 404 (Not Found)
* Null status: 202 (No content)
* Internal Server Error: 500 
* Missing Params: 400 (bad request)
* Express Middleware :- Which allow us to read the data from the user(postman body) and write our document.
  app.use(express.json());
//to convert the id into int
  const id=parseInt(req.params.id);
  or
  const id= req.params.id *1; 
patch method :- Update the only desired value from the database.
put method :- Update the whole database 
delete method :- Delete the whole database
* Custom middleware : Every time it will be execute whenever any request will be send.
* morgan : used as a middleware to identify the request.
  $ npm i morgan
* Install morgan only for developemnt env
  $ npm i morgan --save-dev  
MVC Model: Model-Veiw-Controller
Serving Template: Access the static files using express
app.use(express.static(`${__dirname}/nft-data/img`));
.env file :
  $ npm i dotenv
// To start the application in development environment
  $ npm start
// To start the application in production environment
  $ npm run start:prod   
* MongoDB Connection :
  $ npm install mongodb
  $ npm i mongoose@5.5.2
* Remove the folders and files from git
  $ git rm -r "folder name"
  $ git rm "file name"
* Add the config files in .gitigone file

  $ echo ".env" >> .gitignore
  $ git rm --cached .env
  $ git add .gitignore

About

To develop a REST API for an NFT marketplace, you can use Node.js for the backend server and MongoDB as the database. This API will facilitate various operations related to NFTs, such as creating, listing, buying, and transferring non-fungible tokens on the marketplace.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published