- Codersquare is a social web app for sharing learning resources in hacker news style by making posts with avilability to comments on as well as votes/likes.
- It's and implementation of the original Codersquare project in javascript and nodejs with express.
A simple HTTP server is responsible for authentication, serving stored data, and potentially ingesting and serving analytics data.
- Node.js is selected for implementing the server for speed of development.
- Express.js is the web server framework.
- Sequelize to be used as an ORM.
A JWT-based auth mechanism is to be used, with passwords encrypted and stored in the database.
The API is described in detail in this OpenAPI documentation
Users:
/users/login [POST]
/users/signup [POST]
/users/logout [GET]
Posts:
/posts/:id [GET]
/posts/:id [DELETE]
/posts/ [POST]
/posts/ [GET]
Comments:
/comments/:postid [GET]
/comments/:id [DELETE]
/comments/ [POST]
Likes:
/likes/:postid [GET]
/likes/ [DELETE]
/likes/ [POST]
A relational database (schema follows) to fast retrieval of posts and comments. A minimal database implementation such as sqlite3 suffices.
Users:
Column | Type |
---|---|
ID | STRING/UUID |
username | STRING |
STRING | |
firstName | STRING |
lastName | STRING |
password | STRING |
loggedIn | BOOLEAN |
Posts:
Column | Type |
---|---|
ID | STRING/UUID |
title | STRING |
body | STRING |
userId | STRING/UUID |
createdAt | Timestamp |
Likes:
Column | Type |
---|---|
userId | STRING/UUID |
postId | STRING/UUID |
Comments:
Column | Type |
---|---|
ID | STRING |
userId | STRING/UUID |
postId | STRING/UUID |
body | STRING |
createdAt | Timestamp |
- First you need to clone the repo:
$ git clone https://github.com/IslamWalid/codersquare.git
- Install dependencies
$ npm install
- Start server
$ npm start
NOTE: you need to specify the following environment variables:
JWT_SECRET
: string used by jwt to encode and decode tokensDB_FILE
: sqlite database file pathPORT
: listening port