A simple Ticketing System made using node/express/mongo. User types are "admin", and "employees". Ticket CRUD operations, closing a ticket according to their priority, etc. Used TypeScript as the dev language [code is in ./src
], for js
implementation look for ./dist
folder.
Live at heroku
git clone https://github.com/SD170/nodejs-ticketing-system
On the project root folder, run:
npm install
Run MongoDB as a service, and make sure to know the port no (27017 by default). For Ubuntu (in my case) to start MongoDB as a service run the following commands in a terminal:
sudo service mongod start
after that:
mongosh
this will start the service. So, let it keep running.
We have used MongoDB as our database. So, in order to connect to the local database, we'll need 3 values, and we've kept it in config.env in tha path- /config:
- Create a file named config.env inside the folder, /config.
- Add 3 env variables eg:
MONGOHOST=localhost MONGOPORT=27017 MONGOUSER=<Your user> MONGOPASSWORD=<Your pass> DATABASENAME=<Your DB name>
From the root folder, start the project by running:
npm start
In case you have Postman installed, you can import the endpoints with documentation inside
_data/Schedule management system.postman_collection.json
or click here.
Otherwise, I'm adding the endpoints with a brief description and `the live links.
1) /api/v1/users/new [Method: POST]
Creates a user, admin/employee.
Authorization: jwt < JWT token of the user > [returned form /api/v1/users/new
]
username: Username of the user [Must be unique] [REQUIRED]
role: Role of the user [options: admin/employee]
Empty
Public
1) /api/v1/tickets/new [Method: POST]
Creates a new ticket.
Authorization: jwt < JWT token of the user > [returned form /api/v1/users/new
]
title: Title of the ticket [Must be unique] [REQUIRED]
description: Ticket description [REQUIRED]
assignedTo: Username of the employee [REQUIRED]
status: status [options: open/close, default: open] [optional]
priority: priority [options: high/medium/low, default: low] [optional]
Empty
Private: Admin
2) /api/v1/tickets/all [Method: GET]
List all tickets.
Empty
Empty
Empty
Public
3) /api/v1/tickets [Method: GET]
Query all tickets.
Empty
Empty
title: Title of the ticket
status: status [options: open/close, default: open]
priority: priority [options: high/medium/low, default: low]
Public
4) /api/v1/tickets/markAsClosed [Method: POST]
Closes a ticket [Only if there's no high priority ticket assigned to the employee
]
Authorization: jwt < JWT token of the user > [returned form /api/v1/users/new
]
ticketID: Id of the ticket [REQUIRED]
Empty
Private: Assigned Employee or Admin
5) /api/v1/tickets/delete [Method: POST]
Deletes a ticket
Authorization: jwt < JWT token of the user > [returned form /api/v1/users/new
]
ticketID: Id of the ticket [REQUIRED]
Empty
Private: Admin
Our schedule management system backend has the following tech stack.
- node.js - For backend runtime.
- Express.js - For easily creating the REST API.
- MongoDB - As the Database. mongoose for object modeling in node.
- TypeScript - As the dev language.
- Git - For source control.