@fof-nestjs/core v0.2.48
@fof-nestjs/core
Backend core package for mini-service
Backend core packages for implementing mini-servcie architecture. Based on Nest framework TypeScript starter repository.
New project
Prerequisites
Node.js
Make sure your development environment includes Node.js and an npm package manager. This framework requires a current, active LTS, or maintenance LTS version of Node.js
- To get Node.js, go to nodejs.org.
npm package manager
This setup guide uses the npm client command line interface, which is installed with Node.js by default.
NestJS
# install the Nest CLI (NestJS)
$ npm i -g @nestjs/cli
# create a new project
$ nest new project-name-back
Test to verify everything is fine with just NestJs
$ cd project-name-back
$ npm install
$ npm run start
Open your browser and navigate to http://localhost:3000/.
Install the main package
$ npm i @fof-nestjs/core --save
execute the postinstall script
./node_modules/@fof-nestjs/core/ressources/postinstall.sh
# copy .env config file
# install @nestjs/swagger swagger-ui-express
# install swagger-stats
Update the src/main.ts file
import { fofAppConfig, fofBoostrapStats } from '@fof-nestjs/core' // <- MUST be in first
import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
async function bootstrap() {
const app = await NestFactory.create(AppModule)
await fofAppConfig(app)
await app.listen(3000)
await fofBoostrapStats(app)
}
bootstrap()
Update the src/app.module.ts
//...
import { Module } from '@nestjs/common'
import { AppController } from './app.controller'
import { AppService } from './app.service'
import { FofCoreModule } from '@fof-nestjs/core' // <-- add this
// your custom actions for access management
enum eP { // <-- add this
invoiceCreate = 'invoiceCreate',
invoiceUpdate = 'invoiceUpdate',
invoiceRead = 'invoiceRead',
invoiceDelete = 'invoiceDelete'
}
@Module({
imports: [
FofCoreModule.forRoot({ // <-- add this
permissions: eP,
isMasterForUserManagement: true,
isMasterForMiniServicesManagement: true,
isMasterForOrganizationManagement: true,
}),
],
controllers: [
AppController
],
providers: [
AppService
],
})
export class AppModule {}
Update the .env file. Uncomment TYPEORM_DROP_AND_SYNCHRONIZE
and set it to true to create local database file in SQLlite3
# default is false, be carreful in production !!
TYPEORM_DROP_AND_SYNCHRONIZE=true
change the technical name (no space, no special charactere) and the service name
# technical name for message broker, caching, logs, etc
SERVICE_TECHNICAL_NAME=my-app
# friendly name for displaying in API docs etc
SERVICE_NAME=My wonderfull app!
test to verify if everything is fine
# dev mode
$ npm run start:dev
# OR for debug mode
$ npm run start:debug
You should see something like that, it means the server is up and database is succesfully created
┌────────────────────────────────────────────────────────────┐
| Service my-app successfully started
| Listen on port http://[::1]:3000
| Bootstrap done in 1197.404ms
| Memory: Used 71.86Mb of 91.32Mb - RSS: 127.80Mb
└────────────────────────────────────────────────────────────┘
- Open your browser and navigate to http://localhost:3000/.
- Hello word, the server is up
- Open your browser and navigate to http://localhost:3000/docs/apis/.
- Documentation API
Your backend is now ready with user, access management and authentication. At least. A default user is created
- login:
superuser@fof.com
- password:
changeMe
Note
ToDo
Change Logger for pino
Have a look on
test
Publish with dist in git. e.g. (should support the npm update) npm install --save git+ssh://git@github.com:fofBdx/fof-core-shared.git during dev, from local npm install /relative_path
Installation
- at the root folder, create a config folder
- create a .env file inside the config folder
$ npm install
Running the app
# development
$ npm run start
# watch mode
# run lib and app-test in watch mode
$ npm run workspace-dev
$ npm run start:dev
# production mode
$ npm run start:prod
Test
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
Stay in touch
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
License
Nest is MIT licensed.
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago