Skip to content

victorbadaro/node-api-rawsql-example

Repository files navigation

node-api-rawsql-example

LEIAME.md

Summary

🧾 About

This project was made to be a simple example of a back-end application using raw SQL (no ORMs or Query builders)

🚀 Main technologies

(You can see all the dependencies in the package.json file)

💻 Usage

As you can see on 🚀 Main technologies topic, this application depends on a postgreSQL database, so you must have it installed. First things first:

  1. Clone the project (you'll need a personal access token):

    $ git clone https://github.com/victorbadaro/node-api-rawsql-example.git
  2. Access its directory:

    $ cd node-api-rawsql-example
  3. Install its dependencies:

    $ yarn
    # feel free to use another package manager, but you might want use yarn once there's already a yarn.lock file in the root directory
  4. Access your PostgreSQL server and create the database (you can use any name):

    CREATE DATABASE node_api_rawsql_db;
  5. Run the SQL commands that is in database.sql file

  6. Create a .env file in the root directory with the same content that is in the .env.example file and fill the variables with your own data:
    For example:
    image

  7. Start the server by running the dev script:

    yarn dev

👌 Requests

Now the server is ready to receive your requests! There's a request collection in the root directory so you can use (use insomnia to import the collection). Remember to inform the server port in the baseUrl environment variable!
Here are the requests you can make:

  • GET /users

  • POST /users

    {
      "name": "",
      "email": ""
    }
  • GET /users/:id

  • PUT /users/:id

    {
      "name": "",
      "email": ""
    }
  • DELETE /users/:id

  • GET /products

  • POST /products

    {
      "description": "",
      "user_id": 
    }
  • GET /products/:id

  • PUT /products/:id

    {
      "description": "" 
    }
  • DELETE /products/:id


This project was created and developed with ❤ by Victor Badaró