All Templates / Starters
Express.js + Passport.js starter
A simple service with fundamental components setup.
service
railwayapp-templates/expressjs-passport-starter
Just deployed
Express.js
+ Passport.js
starterThis template deploys a simple service with fundamental components setup, built-in authentication/authorisation, and a fairly organised codebase.
Although important notes will be presented here, it is recommended to explore and emerge yourself in a
dfs
way, starting here, as there exists plenty comments that will may or may not help you.
Express.js
application with Passport.js
to protect your precious todos, as well as chai
on mocha
for testing.
src/core/attach-routes.js
or src/core/attach-middlewares.js
.src/core/attach-middlewares.js
are application-level middlewares. They could all be categorised into the following types (1) chore middlewares, i.e. cors
, csrf
, etc. (2) business middlewares, which play some parts in the logic of your service.src/modules/account/account.controller.js
is an example implementation. But remember, ensureAuthenticated
is placed in the common src/middlewares/index.js
because it will also be used in other routes and modules; if what you have is local to, say the account
module, please put it there. (account.middleware.js
is not a bad name)dotenv
built-in, because Railway
injects environment variables at runtime. Do install if you are using this starter, not just reading it as a way to procrastinate your life (but thank you!).This is separated from the above section because I have actually tried a few testing frameworks, and chai
's interface is by far the most convenient to work with. Most of the time, you would want to test route handlers' business logic (TDD), or a fragment of the service flow (BDD), and chai
's should
APIs or the normal expect
s are really sweet. Anyway, just organise your test files as per the existing structure, but technically any file in the __test__
directory that has the .test.js
extension will be included if you run the predefined test
script.
dev
script uses Node.js
v18 experimental --watch flag. If you cannot handle it, please implement nodemon
or pm2
yourself.Template Content
Details
edmond.w's Projects
Created on Sep 13, 2023
72 total projects
41 active projects
100% success on recent deploys
JavaScript
Starters
More templates in this category
Django Monolith
A Django app connected to a Postgres database with Celery and Celery Beat.
Odogwu Machalla's Projects
37