Basically, this is a boilerplate of:
- MongoDB
- Express.js
app - ESLint and Prettier integrated
- API Docs generation
- Basic sanitization of
parametersfor APIs
for deta.sh. Although, pretty sure, it will also work for other platforms too.
Something like this: helloworld
Get to know what Deta.sh really is.
In short, a better Heroku.
This boilerplate uses apidoc to generate necessary docs for your micro service API. So get to know the basics.
In short, /src/templates/apidocs_template should not be touched. Same advice goes for /src/static_files.
npm run devwould generate the docs and you can then do local development.
In the .env file:
- set the
MONGODB_URLyour connection string. - set the
DB_COLLECTIONyour collection name i.e.helloworldetc.
try {
const db = await mongodb.connect(mongodbUrl, {
useUnifiedTopology: true,
useNewUrlParser: true,
})
if (isTest === false) {
log.notify(true, null, 'Successfully connected to MongoDB')
}
this.itSelf = db.db(mongodbName)
this.myCollection = this.createCollection(whateverNameOfYourCollection)
} catch (err) {
log.notify(
. . .
}Here replace the following line
this.myCollection = this.createCollection(whateverNameOfYourCollection)with your own collection name.
index.js~ this should not be touched or you risk breaking deta.sh deployment./src/app.js~ this is your mainappand do whatever tweaks and changes needed.