curl -fsSL https://raw.githubusercontent.com/Mario-35/Stean/main/scripts/stean.sh -o stean.sh && chmod +x stean.sh && ./stean.sh
If you need help
The menu differs depending on the progress of the installation but the header and footer of the menu display certain states:- Path: the installation path of the API The best proctice is to install on current folder.
- The version of stean installed
- The state of stean (RUN or STOP) The best practice is to create script run and use it by exit this script.
- At the bottom of the menu the version of node and postgresSql
- Quit to exit installation script
- "Indicate path" or "Change path" : indicates the installation path of the api
- "Check postGis" : test the existence and the version of postGis
- "Install all" : Install stean after check if nodeJs, Postgres and pm2 are installed
- "Back to previous" : If a backup is present install it instead of actual installed stean
- "Create / Recreate run script" : create run.sh with all parameters
- "Run / Stop stean" : run or stop API (if configuration.json is found)
after install : (if localhost) http://localhost:8029/ show the documentation http://localhost:8029/i (any word after will show first install)
The configuration.json file must be found by the api in the configuration folder if the file not exist the api redirect you to th first install page to create that file with your firs service :
{
// admin must be in configuration file
"admin": {
"name": "admin",
"ports": {
"http": 8029, // http port
"tcp": 9000, // tcp port for mqtt
"ws": 1883 // web socket
},
// postgresSql Connection // with admin rights (create database rights and user ...)
"pg": {
"host": "localhost",
"port": 5432,
"user": "postgres",
"password": "password", // ADMIN password (with rights to create DB)
"database": "postgres",
"retry": 2
}
},
"myService": { // service name
"name": "myService", // name of the service SAME as key name
"port": 8037, // not used
// postgresSql Connection
"pg": {
"host": "localhost",
"port": 5432,
"user": "myname", // user to create
"password": "myPass",
// name of the database (if not exit a blank database will be create)
"database": "myservice",
"retry": 2
},
"apiVersion": "v1.1", // model version 1.0 ou 1.1
"date_format": "DD/MM/YYYY hh:mi:ss", // date format in jsons
"nb_page": 200, // pagination number by page
// list of alias name
"alias": [
""
],
// etensions of the service
"extensions": [
"base", // SensorThings core
"multiDatastream", // SensorThings Multidatastream Extension
"lora", // Lora Extension
"logs", // Logs Extension
"file" // File csv serve Extension
"users" // Users Extension
],
"options": [
"highPrecision", // float8 will be used instead of float4
"canDrop", // database can be destroy (usefull in testing phose)
"stripNull", // null value are not visible,
"forceHttps" // force api to add s to http of this service,
]
},
"myServiceNumber2": {
...
}
}
use on local windows as production (for testing) use : script as install.ps1
- Fork/Clone : https://github.com/Mario-35/Stean.git
- Install dependencies : npm install
- Fire up Postgres WITH Postgis on the default ports
- Make configuration.json file or use first install (the file will be automatically create)
- npm run dev for dev, npm run build (vs script package.json)
- If database not exists the program create it. note that db test is automaticly create
Tech Stack
The project run under nodeJS.
📦src
┣ 📂server // API Server
┃ ┣ 📂authentication // authentication and tokens
┃ ┣ 📂configuration // Configuration Server
┃ ┃ ┣ 📜.key // crypt Key
┃ ┃ ┗ 📜 configuration.json // configuration file
┃ ┣ 📂db
┃ ┃ ┣ 📂createDb // datas to create blank Database
┃ ┃ ┣ 📂dataAccess
┃ ┃ ┣ 📂entities // SensorThings entities
┃ ┃ ┣ 📂helpers
┃ ┃ ┣ 📂monitoring
┃ ┃ ┣ 📂queries
┃ ┃ ┗ 📜constants.ts // Constants for DB
┃ ┣ 📂enums // Enums datas
┃ ┣ 📂helpers // Application helpers
┃ ┣ 📂log // Logs tools
┃ ┣ 📂lora // loras functions
┃ ┣ 📂messages //all messages of the api
┃ ┣ 📂models //model descriptor
┃ ┣ 📂odata // Odata decoder
┃ ┃ ┣ 📂parser // Odata parser
┃ ┃ ┗ 📂visitor // Odata decoder process
┃ ┃ ┣📂builder // Odata builder process
┃ ┃ ┣📂helper // Odata helpers
┃ ┃ ┗📂pg // Odata postgres visitor
┃ ┣ 📂routes // routes API
┃ ┃ ┗ 📂helper // routes helpers
┃ ┃ ┣ 📜protected.ts // protected routes
┃ ┃ ┗ 📜unProtected.ts // open routes
┃ ┣ 📂types // data types
┃ ┣ 📂views // generated view
┃ ┃ ┣ 📂clas // class files
┃ ┃ ┣ 📂css
┃ ┃ ┣ 📂helpers // views helpers
┃ ┃ ┣ 📂html
┃ ┃ ┗ 📂js
┃ ┣ 📜constants.ts // App constants
┃ ┗ 📜index.ts // starting file
┣ 📂template // ApiDoc template
┣ 📂test
┃ ┣ 📂integration // Tests
┃ ┃ ┗ 📂files // files For importation tests
┃ ┣ 📜apidoc.json // Apidoc configuration
┃ ┗ 📜dbTest.ts // DB test connection
┗ 📜build.js // js file for building app