https://github.com/jitendragangwar123/rest-api-for-nfts
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.
https://github.com/jitendragangwar123/rest-api-for-nfts
ethereum-api javascript mongodb nfts nodejs
Last synced: about 2 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/jitendragangwar123/rest-api-for-nfts
- Owner: jitendragangwar123
- Created: 2023-06-06T06:36:52.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-06T12:47:54.000Z (almost 2 years ago)
- Last Synced: 2025-03-03T23:13:07.806Z (about 2 months ago)
- Topics: ethereum-api, javascript, mongodb, nfts, nodejs
- Language: JavaScript
- Homepage:
- Size: 8.93 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rest-API-For-NFT
To build the Rest-API for NFT Marketplace using NodeJs and MongoDB.
```shell
$ npm init
$ npm i express@4
$ sudo npm install -g nodemon
``````shell
* 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)
``````shell
* Express Middleware :- Which allow us to read the data from the user(postman body) and write our document.
app.use(express.json());
```
```shell
//to convert the id into int
const id=parseInt(req.params.id);
or
const id= req.params.id *1;
``````shell
patch method :- Update the only desired value from the database.
put method :- Update the whole database
delete method :- Delete the whole database
``````shell
* 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
``````shell
MVC Model: Model-Veiw-Controller
Serving Template: Access the static files using express
app.use(express.static(`${__dirname}/nft-data/img`));
``````shell
.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
```
```shell
* MongoDB Connection :
$ npm install mongodb
$ npm i [email protected]
``````shell
* Remove the folders and files from git
$ git rm -r "folder name"
$ git rm "file name"
``````shell
* Add the config files in .gitigone file$ echo ".env" >> .gitignore
$ git rm --cached .env
$ git add .gitignore
```