This project is an API built for our solution to this brief
- Open up
GitBash
terminal and navigate to the directory you wish to store the project in - Clone the repo to your folder using this command
git clone git@github.com:yrossan/florin_server.git
- Navigate to the
florin-server
folder using this command
cd florin_server/
- Install required packages using this command
npm install
- Create a
SQL
server and and get the connection URL we would reccomendelephantSQL
but you can use another method - Open your code editor by running this command in your GitBash terminal
code .
- Create a
.env
file in theflorin_server/
add your connection URL in aDB_URL
variable and the port you wish the server to listen on in aPORT
variable as shown below
DB_URL='postgres://username:password@horton.db.elephantsql.com/dbname'
PORT=3000
- Setup the database with mock data by running this command in your GitBash terminal
npm run setup-db
- Now you can run the server with this command
npm run dev
- You are now ready to start using the API endpoints
GET /posts
= All postsGET /posts/:id
= Find post by idGET /posts/services
= All posts with ‘Services’ categoryGET /posts/events
= All posts with ‘Events’ categoryGET /posts/jobs
= All posts with ‘Jobs’ categoryGET /posts/voluntary
= All posts with ‘Voluntary Work’ categoryGET /posts/announcements
= All posts with ‘Announcements’ categoryGET /posts/clubs
= All posts with ‘Clubs’ category
DELETE /posts/:id
= delete a post by idPOST /posts
= create a new post with POST request
{
"title": "Title", // Post title
"content": "Main content for post", // Main section of the post
"category": "Services", // must be one of preset categories from GET/posts/... routes
"author_id": 1, // must be user_id of current user
"post_date": "2023-05-11" // must be in YYY-MM-DD format
}
POST /users/register
= register user
{
"username": "User1", // The users username
"password": form.get("password"), // The users password
"isAdmin": isAdminResult, // Optional must be 1 or 0 for true and false respectively
"isBusiness": isBusinessResult, // Optional must be 1 or 0 for true and false respectively
}
POST /users/login
= login user
{
"username": "username", // The users Username
"password": "password", // The users password
}
DELETE /users/logout
= removes all tokens from database where user_id matches current users token user_id
GET /comments/:id
= All comments with post_id = id
- express
- bcrypt
- cors
- dotenv
- morgan
- pg
- uuid
- jest
- nodemon
- supertest
- No known bugs
MIT License: see the LICENSE
file.