Simple Authentication service using the following technologies:
/api
.
├── /auth
│ └── POST
│ ├── /login
| |__/signup
├── /users
│ └── GET
│ PUT
│ DELETE
│ └── /
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. |
-
Users (table)
- id (auto-generated)
- email (string)
- password (string)
- role (enum)
- createdAt (Date)
- updatedAt (Date)
- authoredPosts (Array of blog posts)
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.
- 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
-
Go to your Railway dashboard.
-
Create a new project and connect it to your current repository, deploy it.
-
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:
- Create a
RAILWAY_TOKEN
here under your project settings>tokens.
-
Go to your repository project settings.
-
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.
-
This workflow will be triggered based on the
master
branch.