Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabogit/tickets-server
API rest, jwt & crud
https://github.com/fabogit/tickets-server
express jwt node
Last synced: about 4 hours ago
JSON representation
API rest, jwt & crud
- Host: GitHub
- URL: https://github.com/fabogit/tickets-server
- Owner: fabogit
- Created: 2022-07-13T13:03:14.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-22T16:51:07.000Z (over 2 years ago)
- Last Synced: 2023-03-04T16:02:54.660Z (over 1 year ago)
- Topics: express, jwt, node
- Language: JavaScript
- Homepage:
- Size: 64.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Use case
- main page allow to login/register/logout
- on login ui will load all user available tickets (might add filter to show only the open/closed), data is paginated
- users can create a new ticket
- single tickets can be selected to show full details, admin users can update/delete tickets
auth/roles:
an user can read and create his tickets,
an admin can read all users tickets and update the completed field
access token:
```
Bearer pasteheretheAccessTokenFrom/users/login
```# API
## open api
- `POST` `/users/` -> Register a new user
- `PUT` `/users/:userId` -> logged in user can update username/password // TODO
- `DELETE` `/users/` -> Delete a user if is currently logged in
- `GET` `/users/login` -> Log in the user and create the access token
- `GET` `/users/logout` -> Remove jwt client side || DELETE session ?
## auth api, access token needed
- `GET` `/tickets` -> fetch user tickets /paginated result, ADMINS will get all tickets
- `POST` `/tickets` -> user ticket creation
- `GET` `/tickets/:id` -> get ticket by id
- `PUT` `/tickets/:id` -> ADMINS update ticket status
- `DELETE` `/tickets/:id` -> ADMINS delete ticket
- `POST` `/messages/:ticketId` -> ADMINS and the ticket owner can create messages
# data schema
collections:
```
users: {
username: string,
password: string,
isAdmin: boolean
}
``````
tickets: {
username: string,
description: string,
isCompleted: boolean(default: false)comunications: [
{
date: Date
userId: ObjectId,
username: string
message: string
}, ...
],
createdAt: Date
updatedAt: Date
}
```to gen token
`node` -> `require('crypto').randomBytes(64).toString('hex')`