Skip to content

First steps

Eicrud plugs itself on a working NestJS application (configured with Fastify). You'll need a database server (MongoDB or PostgreSQL) listening on the right port.

It is recommended to use Eicrud's CLI throughout all your developments since it will maintain a proper directory structure.

First create your nest app as specified in the NestJS documentation.

 npm i -g @nestjs/cli
 nest new project-name
 cd project-name

Then use the CLI to setup your project.

npm i -g @eicrud/cli
eicrud setup mongo project-name 
npm i -g @eicrud/cli
eicrud setup postgre project-name 

Install with git

Alternatively, you can pull a ready app from the starter repository.

git clone https://github.com/eicrud/eicrud-starter.git project-name
cd project-name
npm install

Post Installation

Eicrud needs a secret key to sign JWT tokens, which are used during authentication. You can generate a new one using the node:crypto module.

node -e "console.log(require('crypto').randomBytes(256).toString('base64'));"
Store it in a .env file at the root of your project.
project-name/.env
JWT_SECRET=<generated_jwt_secret>

You also need a local (or remote) database server to use Eicrud. Once you have it running, verify your connection. Check out Mikro-orm's configuration for more info.

project-name/app.module.ts
// ...
   MikroOrmModule.forRoot({
    entities: [...CRUDEntities],
    driver: MongoDriver,
    dbName: "myapp-db",
   }),
// ...
You can start your application to make sure that everything is working.
npm run start

Comments