https://github.com/maurerkrisztian/deno_oak_mongodb_jwt_docker_rest_api_exemple
This is a simple rest api with Deno, oak, Mongodb and jwt tokens.
https://github.com/maurerkrisztian/deno_oak_mongodb_jwt_docker_rest_api_exemple
deno docker docker-compose env jwt-authentication mongodb oak rest-api
Last synced: 2 months ago
JSON representation
This is a simple rest api with Deno, oak, Mongodb and jwt tokens.
- Host: GitHub
- URL: https://github.com/maurerkrisztian/deno_oak_mongodb_jwt_docker_rest_api_exemple
- Owner: MaurerKrisztian
- Created: 2020-10-23T22:38:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-24T14:58:02.000Z (over 4 years ago)
- Last Synced: 2025-01-12T18:52:10.601Z (4 months ago)
- Topics: deno, docker, docker-compose, env, jwt-authentication, mongodb, oak, rest-api
- Language: TypeScript
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deno REST API
This is a simple rest api with Deno, Mongodb and jwt tokens.
## Start up
Create a .env file - exemple: [env.exemple](.env.exemple)
```dotenv
DB_URI =
DB_NAME =
JWT_ACCESS_TOKEN_SECRET =
```
#### Start cmd
```
$ deno run --allow-env --allow-net --unstable --allow-read --allow-write --allow-plugin .\app.ts
```
#### Docker
```
$ docker-compose up --build
or
$ docker build -t app . && docker run -it --init -p 3000:3000 app
```#### Dependencies:
* [oak](https://deno.land/x/oak)
* [[email protected]](https://deno.land/x/[email protected])
* [djwt](https://deno.land/x/djwt)
* [dotenv](https://deno.land/x/dotenv)#### Routes
```
GET /users
GET /users/:id
POST /users
PUT /users/:id
DELETE /usersPOST /login
```### What you can do with this api:
* You can secure a route by adding a middleware and pass a role array:
```typescript
router.get("/", requiredRole(['admin']), async (context: any) => {
context.response.body = "This is a secure api endpoint."
})
```* With the RepositoryService and ControllerService you don't need to rewrite
the CRUD operations each collection just extend the controller class.
```typescript
export class UserController extends ControllerService {constructor() {
super(new UserRepository());
}}
```#### Note:
* This api is still in development.