In the last story, I covered how to setup Prisma. Now we will create Rest APIs using Prisma.
To use Prisma client in Nodejs, first setup Nodejs
A. Project setup * npm init -y * npm i body-parser express — save * npm i webpack webpack-cli — save-dev
- Open server.js and create routes to API:
For authentication first, add the required dependencies to the project:
npm add lodash bcrypt jsonwebtoken
3. In API folder create user.js file for creating RESTful API for the user register, a user login, and user delete.
2. In the API folder create file company.js and add the following code.
In the API folder, create another file employee.js and write the following code.
Run the project by typing the command:
npm run start
Here, You can refer to the previous stories for testing APIs :
We have successfully created Restful APIs using Prisma. 👏