Amplication Data Service Generator is the component that generates the server-side code (models, Prisma client, REST API, authentication, and authorization filters) of the application built with Amplication.
Generate a REST API code using data and access control definitions. The generator can be used as a library or as a CLI.
- Node.js: the generated code is human-editable Node.js code.
- TypeScript: the generator code and the generated code are both strictly typed TypeScript code.
- Nest.js: is used for defining the API.
- Express: is used as the base web framework for Nest.js.
- Passport: is used for providing Basic authentication.
- AccessControl: is used for providing ABAC and RBAC authorization.
- PostgreSQL: is used for storing the application data.
- Prisma: is used to interact with Postgres and define data migrations.
- Docker: the generated code includes a Dockerfile for building containers.
- Morgan: is used for logging calls to the API.
- Recast: is used for generating the TypeScript code.
- Jest: is used for testing the generator code and for testing in the generated code.
💡 Before you begin, make sure you have all the below installed:
- Node.js v14 or above
Should be:
node -v
v14.0.0
or newer - npm v7 or above
Should be:
npm -v
7.0.0
or newer - Docker
Should start with:
docker -v
Docker version
- Git
Should start with:
git version
git version
After cloning the repository open its root directory and run the following commands:
- Install dependencies of the monorepo (execute in root directory):
npm install npm run bootstrap
- Build the Data Service Generator and its dependencies:
npm run build -- --scope @amplication/data-service-generator --include-dependencies
- Open the data service generator directory
cd packages/amplication-data-service-generator
- Generate the test data service app
npm run generate-test-data-service
Make sure you are in the data service generator directory (packages/amplication-data-service-generator
).
Once you are done making changes, run the following commands:
- Format files (editors like VSCode can do it for you automatically)
npm run format
- Lint files (editors like VSCode come with integration to display those continuously)
npm run lint
- Run unit tests
npm test
- (Optional) Rebuild the package
npm run build
Generate an application according to the test data definitions. Once generated you can install its dependencies and start it with npm and spin a database with Docker.
npm run generate-test-data-service
The test will generate code according to the test data definitions, run a Docker container with it, run a database docker container, and try to call the API endpoints. Make sure to build the library before executing it.
npm run test:e2e
npx lerna add --scope server-template $NAME_OF_DEPENDENCY
npx lerna add --scope admin-template $NAME_OF_DEPENDENCY