0.1.25 • Published 2 years ago
mao-core v0.1.25
Mão Core
mao-core
is a library that can be used to implement microservices.
Getting started
Create a new Node.js project:
npm init
Create a directory for your project with the following structure:
- package.json
- app/
- .env
- index.js
- config/
- config.json
Edit the package.json
file as follows:
"main": "app/index.js",
"scripts": {
"start": "nodemon app/index.js"
},
"dependencies": {
"mao-core": "^0.1.0"
},
"devDependencies": {
"nodemon": "^2.0.15"
}
Create the file app/index.js
with the following content:
// Internal dependencies
const App = require(`mao-core`).App;
// Create the app
let app = new App
(
[
// Create your controllers here
]
);
// Start the app
app.start().catch
(
(error) =>
{
console.log(error.message);
}
);
Create the file app/config/config.json
with the following content (don't forget to replace "your-service-code"
):
{
"mao":
{
"core":
{
"registry": {"ENV": "MAO_CORE_REGISTRY"},
"service":
{
"name": "your-service-code",
"url": {"ENV": "MAO_CORE_SERVICE_URL"}
},
"server":
{
"host": {"ENV": "MAO_CORE_SERVER_HOST"},
"port": {"ENV": "MAO_CORE_SERVER_PORT"}
}
}
}
}
Create the .env
file with the following content:
MAO_CORE_REGISTRY=http://localhost:8080
MAO_CORE_SERVICE_URL=http://localhost:8081
MAO_CORE_SERVER_HOST=localhost
MAO_CORE_SERVER_PORT=8081
Install dependencies:
npm install
Start the app:
npm start
0.1.25
2 years ago
0.1.24
2 years ago
0.1.23
2 years ago
0.1.22
2 years ago
0.1.21
2 years ago
0.1.20
2 years ago
0.1.19
2 years ago
0.1.18
2 years ago
0.1.17
2 years ago
0.1.16
2 years ago
0.1.15
2 years ago
0.1.14
2 years ago
0.1.13
2 years ago
0.1.12
2 years ago
0.1.11
2 years ago
0.1.10
2 years ago
0.1.9
2 years ago
0.1.8
2 years ago
0.1.7
2 years ago
0.1.6
2 years ago
0.1.5
2 years ago
0.1.4
2 years ago
0.1.3
2 years ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago