A simple express server with mongoose (ODM) with typescript and a client app (Vite/React) to manage the blog posts and other data. Demo https://blog.floatrx.net/
Note
The main goal is to demonstrate how MongoDB works with Express server in Node.js, using the Mongoose ODM. I created a simple client-side part for demonstration purposes. For a search engine-friendly blog, it's best to go with Next.js.
Check the mongodb README for more information.
yarn dev
Note
Mount the mongo
container before running the server.
- OAuth2 (GitHub)
- find post by author tag
- paginate posts
- find posts by tag
- Setup mongo with docker or use a cloud service
- Setup server with pm2 and nginx (check ecosystem.config.js for more information)
- Setup client with nginx
# API
server {
server_name blog-api.floatrx.net;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
error_log /var/log/nginx/blog-api-error.log;
}
# CLIENT
server {
server_name blog.floatrx.net;
root /var/www/blog;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
Note
Use certbot to generate SSL certificates.
Happy coding! 🚀