This example shows how to implement a REST API with TypeScript using Express and Prisma Client to resolve challenge.
Bearer auth, or token authentication, is an HTTP authentication scheme which comprises security tokens called bearer tokens. The token is usually a cryptic string, and is generated in response to a successful login on the part of a user.
A client must include this token in the Authorization header when making requests to any protected resource on the server. As I have stated I use JWT tokens but of course you can use any type of token you choose.
Clone this repository:
git clone [email protected]:Daniek3d/auth-prisma-mongo.git
Install npm dependencies:
cd auth-prisma-mongo
npm install
Note that this also generates Prisma Client JS into node_modules/@prisma/client
via a npx prisma generate
hook of the @prisma/client
package from your package.json
.
Execute this command to start the server:
npm run dev
The server is now running on http://localhost:3000
. You can send the API requests implemented in api-todo.js
, e.g. [http://localhost:3000/
]
(http://localhost:3000).
Exist example how to access the api in the directorio test, using vscode api rest plug in.
You can access the REST API of the server using the following endpoints:
POST http://localhost:3000/api/v1/auth/login content-type: application/json
{ "email": "[email protected]", "password": "12345" }
POST http://localhost:3000/api/v1/auth/user content-type: application/json
{ "email": "[email protected]", "name": "test2", "password": "12345" }