This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Node.js 4.2.4 or higher is required.
If this is a brand new project, make sure to create a package.json
first with the npm init
command.
Installation is done using the npm install
command:
npm install equipped
yarn add equipped
Before use, the package must be initialized in the entry point into your application, with the required settings.
import { Instance } from 'equipped'
Instance.initialize({
isDev: true, // Are you running in a dev environment
appId: 'testing', // An id to identify your application
mongoDbURI: 'mongodb://...', // A mongodb url if you want to use a database
redisURI: 'redis://localhost:6379', // A redis url if you want to use a redis cache. Confirm all other functionality you intend to use do not depend on the cache, even if you are not using a cache directly
...other settings
})
After the app has been initialized, the Instance class returns a singleton that provides access to most functionality provided by Equipped
import { Instance } from 'equipped'
const appInstance = Instance.get()
To start a server
import { makeController, StatusCodes } from 'equipped'
// Aggregate all your routes into an array. This can be defined in the file or imported from your controllers etc
appInstance.server.routes = [
{
path: '/',
method: 'get',
controllers: [makeController(async () => {
return {
result: 'Hello world',
status: StatusCodes.Ok
}
})]
}
]
await appInstance.server.start(8080)