simple nodejs repo to practice different build strategies
|
|
há 1 semana atrás | |
|---|---|---|
| bin | há 1 semana atrás | |
| helm | há 1 semana atrás | |
| images | há 1 semana atrás | |
| lib | há 1 semana atrás | |
| openshift | há 1 semana atrás | |
| public | há 1 semana atrás | |
| test | há 1 semana atrás | |
| tests | há 1 semana atrás | |
| views | há 1 semana atrás | |
| CHANGELOG.md | há 1 semana atrás | |
| LICENSE | há 1 semana atrás | |
| Makefile | há 1 semana atrás | |
| OTEL.md | há 1 semana atrás | |
| README.md | há 1 semana atrás | |
| app.js | há 1 semana atrás | |
| logger.js | há 1 semana atrás | |
| package-lock.json | há 1 semana atrás | |
| package.json | há 1 semana atrás | |
| server.js | há 1 semana atrás | |
| tracing.js | há 1 semana atrás |
Example CRUD Application
First, install the dependencies
npm install
A Postgres DB is needed, so if you are using Docker, then you can start a postgres db easily.
docker run --name os-postgres-db -e POSTGRESQL_USER=luke -e POSTGRESQL_PASSWORD=secret -e POSTGRESQL_DATABASE=my_data -d -p 5432:5432 centos/postgresql-10-centos7
In this example, the db user is luke, the password is secret and the database is my_data
You can then start the application like this:
DB_USERNAME=luke DB_PASSWORD=secret ./bin/www
Then go to http://localhost:8080
Other options:
npm run dev same as npm start but with pretty output log.npm run dev:debug shows debug information.First, make sure you have an instance of Openshift setup and are logged in using oc login.
Then create a new project using the oc commands
oc new-project fun-node-fun
For this example, you will also need a postgres db running on your Openshift cluster.
oc new-app -e POSTGRESQL_USER=luke -ePOSTGRESQL_PASSWORD=secret -ePOSTGRESQL_DATABASE=my_data centos/postgresql-10-centos7 --name=my-database
Then run npm run openshift to deploy your app
Run the following command to show the newly exposed route that you can navigate:
oc get route nodejs-rest-http-crud
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
nodejs-rest-http-crud nodejs-rest-http-crud-opentel.apps-crc.testing nodejs-rest-http-crud 8080 None