import { INestiaConfig } from "@nestia/sdk";
import { NestFactory } from "@nestjs/core";
// import { FastifyAdapter } from "@nestjs/platform-fastify";
import { YourModule } from "./src/YourModule";
const NESTIA_CONFIG: INestiaConfig = {
input: async () => {
const app = await NestFactory.create(YourModule);
// const app = await NestFactory.create(YourModule, new FastifyAdapter());
// app.setGlobalPrefix("api");
// app.enableVersioning({
// type: VersioningType.URI,
// prefix: "v",
// })
return app;
},
output: "src/api",
distribute: "packages/api",
};
export default NESTIA_CONFIG;
The best to way to distributing SDK library is just publishing as an NPM module.
Configure distribute
property of nestia.config.ts
file, and run npx nestia sdk
command. After that, distribution environments would be automatically composed with SDK library generation. At last, move to the packages/api
directory, and run npm run deploy
command for publishing.
From now on, client developers can use the SDK library just by using npm install
command.
cd packages/api
npm run deploy
Of course, before publishing the NPM module, you’ve to customize some configurations like package name. Initial name of the distribution envirionments is @ORGANIZATION/PROJECT-api
, but you must change the package name of yours, isn’t it?
Also, if your SDK library utilize special alias paths
, you also need to customize tsconfig.json
file, too. Reading below example package.json
and tsconfig.json
files generated by nestia
, consider which features to customize.
{
"name": "@ORGANIZATION/PROJECT-api",
"version": "0.1.0",
"description": "SDK library generated by Nestia",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"scripts": {
"build": "npm run build:sdk && npm run compile",
"build:sdk": "rimraf ../../src/api/functional && cd ../.. && npx nestia sdk && cd packages/api",
"compile": "rimraf lib && tsc",
"deploy": "npm run build && npm publish"
},
"repository": {
"type": "git",
"url": "https://github.com/samchon/nestia"
},
"author": "Jeongho Nam",
"license": "MIT",
"bugs": {
"url": "https://github.com/samchon/nestia/issues"
},
"homepage": "https://nestia.io",
"devDependencies": {
"rimraf": "^5.0.0",
"typescript": "^5.4.2",
"ts-patch": "^3.1.0"
},
"dependencies": {
"@nestia/fetcher": "^4.2.0",
"typia": "^7.3.0"
},
"files": [
"lib",
"package.json",
"README.md"
]
}