‼️ 📣ATTENTION: This app may take a couple of minutes to load due to the limitations of Render's Free web service.
Thank you for your patience❣️
Index page shows a list of blogs/links. Scrolling down the page will send requests to the server and load more blogs in chunks.
Guest users have read-only access to blog posts, and other content on the website. This restriction is implemented by conditional rendering in the views that may show different content depending on the authenication status.
Immediately upon signing up, a user document is created in the database and the user can log in to their account and see authorized-user-only options.
Authorized users can (for the time limited by the validity of the session cookie) post and edit blogs. The user can log out manually or they will be logged out automatically when the cookie expires. Any attempts to perform authorized-user-only actions upon token expiration will be followed by redirection to the page with error message and automatic redirection to the index.
All users can enable live update feature and see all current blog and user activities.
Certain routes have been implemented with caching mechanisms.
- The number of users and blogs in the database is limited and each will be subjected to automatic deletion, oldest first, when the limit is reached;
- Request rate limit has been set up and the server will respond with error and block client requests whenever the limit is reached;
- Live update closes when navigating to a different page;
- Clone repository;
- Install dependencies -
npm install
; - In the root directory, run:
openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout key.pem -out cert.pem -subj "/CN=localhost" -days 365
to create self-signed security certificate to bypass strict policies of some browsers (like Chrome); - Run the development server -
npm run dev
; - Run tests -
npm run test
; - IMPORTANT: you have to explicitly type
https
to open the app in your browser in dev mode, example: https://localhost:3002. This is necessary because in dev environment, https Node module is used to create the server.
- NodeJS - Server logic
- Express - Routing
- Express rate limit - Request rate limiting
- EJS - Templating
- Express EJS layouts - Building reusable layouts
- MongoDB - Database
- Mongoose - MongoDB document modelling
- Dotenv - secret-keeping
- Passport - authentication middleware
- Passport local - passport local auth strategy (username & password)
- Connect mongo - session store
- Connect flash - storing and retrieving flash messages
- Node cache - caching
- WS - Node.js WebSocket library
- Mocha - JavaScript testing framework
- Chai - testing library
- Chai-http - testing HTTP requests
- MongoDB Memory Server - testing/mocking MongoDB memory server in NodeJS
- mongodb - MongoDB driver for NodeJS
- nyc - test coverage report
If you want to run the app in your local environment, you'll need to create a .env file in the root directory and provide values for the variables below.
MONGO_URI=
TEST_MONGO_URI=
SECRET=
HOST= #-- Should be https://localhost:{port_number} for live update to work under browser security restrictions
WSS_HOST= #-- Should be wss://localhost:{port_number}
TEST_PORT=
PORT=
DOMAIN=
PER_PAGE_LIMIT=
TEST_MAX_USERS_LIMIT=
TEST_MAX_BLOGS_LIMIT=
MAX_USERS_LIMIT=
MAX_BLOGS_LIMIT=
#Keep in mind the number of user and blog route tests when you're setting test rate limit.
MAX_API_USER_REQS=
TEST_MAX_API_USER_REQS=
API_USER_WINDOW_MS=
TEST_API_USER_WINDOW_MS=
MAX_API_BLOGS_REQS=
TEST_MAX_API_BLOGS_REQS=
API_BLOGS_WINDOW_MS=
TEST_API_BLOGS_WINDOW_MS=
- The enabled state of the live update feature should, ideally, persist in between rendering of different pages;
- Develop a solution to communicate free web service limits to users within the app;
- Test live update feature;
- Test client-side logic;
- Blog chunks should be showing in consistent style. As is, the first chunk to load on scroll appears not to be animated;
- Minify CSS;