Skip to content

Latest commit

 

History

History
127 lines (87 loc) · 3.33 KB

README.md

File metadata and controls

127 lines (87 loc) · 3.33 KB

Express Auth API

Simple Authentication service using the following technologies:

Table of Contents

API Overview

    /api
    .
    ├── /auth
    │   └── POST
    │       ├── /login
    |       |__/signup
    ├── /users
    │   └── GET
    │       PUT
    │       DELETE
    │       └── /

API Detail

Method Path Purpose
POST /auth/login Validates username & password
POST /auth/signup Register a user, generate token.
PRIVATE ROUTES Only accessible for ADMIN role:
GET /users Get all users.
GET /users/:id Get user by id.
PUT /users/:id Update user by id.
DELETE /users/:id Delete user by id.

Business Objects

Prisma Schema

  • Users (table)

    • id (auto-generated)
    • email (string)
    • password (string)
    • role (enum)
    • createdAt (Date)
    • updatedAt (Date)
    • authoredPosts (Array of blog posts)

Run it locally

To build and run this app locally you will need a few things:

  • Install Git
  • Install Node
  • Install PostgreSQL or any DB provider that you want to connect with prisma.

Getting Started

  • Clone the repository
git clone https://github.com/marialastNamedev/verse-bytes.git <project_dir>

Note: wtfunk...my lastName word is confused in Railway as a missing dependency causing a deployment error, just copy the url above using the Code button.

  • Create an .env file based on the example
mv example.env .env
  • Install dependencies
npm install
  • Run it
npm run dev
  • Build it
npm run build

Deploy it

Railway

  1. Go to your Railway dashboard.

  2. Create a new project and connect it to your current repository, deploy it.

  3. Create another service insde the same project for the DB.

Note: This repo includes a GitHub workflow that will do CI/CD for both, the DB and the server. In order for it to work we would need to add some secrets to our repo:

  1. Create a RAILWAY_TOKEN here under your project settings>tokens.

Github

  1. Go to your repository project settings.

  2. Under Security->Secrets and Variables>actions add 3 new repository secrets:

    • RAILWAY_TOKEN create above.
    • RAILWAY_SERVICE_ID cp value under variables in Railway project dashboard.
    • DATABASE_URL cp value under variables from the DB service in Railway project dashboard.
  3. This workflow will be triggered based on the master branch.