This template is configured for the ScaleDynamics platform. It is ready to use to build your own library. All is pre-configured: we provide one command to develop with live reload and one to deploy to make it live on a url.
One particularity of our platform is that you don’t have to manage the Express layers, the platform manages them for you automatically, so you can focus only on the MongoDB/Node/Front coding.
Note that you need a ScaleDynamics account for deployment (create a FREE community account here).
Go in library
folder and run those commands:
npm install
To enter a live-reload development session, use the command below. Feel free to update your code, it will be rebuilt at each change.
npm run dev
Note that when running this command, you have to select a project. On the ScaleDynamics platform, a project identifies an application or a microservice. If you are logged, select an existing project or create a new one. You can also use the platform anonymously by selecting the anonymous
project. For more details on projects, see the documentation.
First you have to compile and minify your project for production
npm run build
Then use your ScaleDynamics account credential to log in to the platform (create a FREE community account here)
npx warp login
Create an environment for your deployment
npx warp env create
This is important. To work properly, your project need the right environment. An environment identifies the cloud execution environment to run your app. You can create as many as you want like ‘staging’, ‘demo’, ‘prod’... Each environment has its own url. When you use it locally, it should be auto
(warp use this by default). But when you deploy it, it should be the name of your environment you use for deployment.
Open the index.js
file in library
. When using the constructor for accessing the backend function, it pass en env
parameter. You can directly change it before deploying or create a .env
file and set your environment through it, Parcel will do his magic and set it up during the build. For more information on how Parcel do it, click here.
Finally, use the deploy command
npm run deploy
Note that when running this command, you have to select an environment.
To deploy, select an existing environment or create a new one. For more details on projects or environments, see the documentation.
This project is divided in two parts:
- the frontend, a
library
template library. - the backend with a node module and a MongoDB module. You can update the frontend/backend as you need to build your own app.
You can create new functions that can be called by the library. Add them in src/index.js
or into another module and export it. The platform manages the Express layers automatically.
const myFunction = () => {
// your code here
}
module.exports = { myFunction };
To access your new functions, you can import your back in a js file and use your function like :
import Microservice from './.microservice/microservice.js';
const { myFunction } = new Microservice({
env: process.env.DEPLOY_ENV || 'auto',
});
If you need more information, you can refer to the documentation:
Copyright 2021 ScaleDynamics SAS. All rights reserved. Licensed under the MIT license.