Skip to content

Backend for create tickets, a RESTful server powered by PostgreSQL and Express.js

License

Notifications You must be signed in to change notification settings

TheRandomCrew/coolticket-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

112 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CoolTicket Server

Forks Stargazers Issues-open Issues-closed Contributors contributions welcome

Logo

Ticket Reservation System

RESTful server powered by PostgreSQL and Express.js

πŸ–ŠοΈπŸž Report a Bug πŸ™‹β€β™‚οΈ Request Feature

Live at coolticket-server.herokuapp.com

Table of Contents

Features

Framework javascript nodejs postgres heroku

  • Async/Await support
  • WinstonJs Logger Implementation
  • Error Handling
  • Postgres Migrations and Seed Support
  • Basic request parameters Validation
  • Open Api Specification implemented through swagger and swagger-ui
  • JWT implementation
  • Enviroment variables to hold configuration values .env file
  • Functional Programming with Middlewares and helpers
  • Standard Coding with Eslint and Prettier, this helps to keep thing into prespective.

JavaScript Style Guide

How to use it

This code is meant to be run in a server accesible online, so other services can use it, in this case a ticket frontend. This is a Rest Api solution using basic database create, read, update and delete operations (CRUD) as well as a basic token (JWT) generator/validator.

I use a RESTful API to be used by any other client, but for human readability I also added swagger (it can even be used as an ad hoc admin panel!). To use it from a client you need to make HTPP(S) requests, for example using curl:

> curl https://coolticket-server.herokuapp.com/ping -v
> curl -d "email=example&password=example2" https://coolticket-server.herokuapp.com/api/v1/auth/login

But you can use any language or library: PHP, GO, C++, Rust, etc. The only unique point is how to manage the JWT. I decided to use a header named x-access-token, in order to avoid a normal way to check for tokens: Autorization: Bearer header. This is just an extra security measure. To send a JWT token for a request in a protected endpoint, you MUST use x-access-token header.

Some interesting endpoints:

  • GET / - Swagger Documentation
  • POST api/v1/auth/login - (email, password) Get a JWT
  • POST api/v1/auth/signup - (email, password, name, userType) Create a new User
  • GET /api/v1/tickets/all - (protected by JWT) Get all the tickets

More info in the swagger documentation Live Here

Getting started

  • Be sure to setup docker-compose and have git.
  • Run this:
> git clone https://github.com/Israel-Laguan/coolticket-server.git
> cd coolticket-server
> docker-compose up
  • Enter localhost:8080 in a browser for the Swagger documentation of the server.

Not a fan of Docker or need more information? Visit the installation instructions to learn more about how to setup your PC for run the server!

Code Overview

This backend's code is made using JavaScript language, and Node.js runtime. With a package named Express.js I managed to create the server, routers and middleware necesary. Also PostgreSQL is used to provide a modern, open sourced and perfomant database layer. Lastly, the server have auxiliar packages for development and deployment to ensure is production ready, enterprise level.

As with most of node.js applications, we would want to install node and npm in our local PC in order to run the server or develop code. This folder include all the necesary files to run the server local or online, just take into account that you'll need to use a terminal as no GUI is available yet.

If you want to develop you have to setup a good dev environment. First of all a good text editor/IDE, I prefer to use Visual Studio Code, but you can use anything else. For the use of VSCode I provide configuration files in the hidden folder .vscode.

For more information about the code please check the code overview.

Author

Contributing

contributions welcome

🀝 Contributions, issues and feature requests are welcome! Feel free to check the issues page. Be sure to review the contributing guidelines.

Happy programming πŸ˜ƒ ✌️

Show your support

πŸ€— Give a ⭐️ if you like this project!

Icons from:

Icons8 Icons8

License

License

πŸ“ This project is licensed under the Apache 2
Feel free to fork this project and improve it

About

Backend for create tickets, a RESTful server powered by PostgreSQL and Express.js

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages