Ahosall / express-api-template

A template created with the intention of making my life easier when starting a project, and the lives of other people. :>

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Express API

A simple and improved api with ExpressJS.

Language PyVersion

🗃 | Dependecies

Dependencie Version
cookie-parser ~1.4.4
cors, ^2.8.5
dotenv ^16.0.2
express ~4.16.1
morgan ~1.9.0
nodemon ^2.0.2

❓ | How to Start?

First let's clone the repository.

$ git clone https://github.com/Ahosall/express-api-template.git

Go to the directory where the project was cloned and we will install the dependencies.

$ npm install

To start the project there are two ways:

  • Production:

    $ npm start
  • Development:

    $ npm run dev

📶 | Routes

I made some changes in the structure of both the code and the folders. The routes are in the src > routes folder. To keep a pattern of files I made a treatment to get the first name of the file.

Example:

clients.route.js

The route in the middle of the names is not mandatory, it's just a way of organizing :>

The code inside each file follows the following structure:

module.exports = [
   {
     path: "/", // Path of the route
     method: "GET", // Method to execute the route
     router: (req, res) => { // Where the magic happens~
         res.json({message: "Hiii, world!"})
     },
   },
]

I did it this way to avoid having to import the router function from express... and to maintain a greater view. :>

🛂 | Controllers & Models

Well, controllers and models follow the same patterns as always, feel free to create an issue with a new way of programming! :>

If you find bugs, report them in the issues. \( ̄︶ ̄*\)

🔰 | License

This project is licensed under the MIT License!


Made with 🤍 by Ahosall (Feh's)!
All forms of contact are on my profile!

About

A template created with the intention of making my life easier when starting a project, and the lives of other people. :>

License:MIT License


Languages

Language:JavaScript 99.5%Language:Shell 0.5%