Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve decorators types #3

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ for JavaScript & Node.js apps powered by TypeScript.

### Binding

There are several ways to inject classes, in the application we use service <strong>identifier binding</strong> and <strong>name binding</strong>.
There are several ways to inject classes, in the application we use service <strong>identifier binding</strong>.

#### Identifier binding

Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@cosmoosjs/core",
"description": "create backend applications quickly and easily with bun.sh",
"version": "1.1.1",
"version": "1.1.2",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/start/bootstrap-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AppBootstrap {

public async defineConfigAndBootstrapApp(config: (injectedConfig: ConfigService) => IBootstrapConfig): Promise<IHttpServe | void> {
let returnedConfig: IHttpServe | void = undefined;
const configService = IocContainer.container.get<ConfigService>(ConfigService);
const configService = IocContainer.container.get(ConfigService);
this.config = config(configService);

this.processEnv();
Expand All @@ -31,7 +31,7 @@ class AppBootstrap {
* Process env variables
*/
private async processEnv(): Promise<void> {
const env = IocContainer.container.get<Environment>(Environment);
const env = IocContainer.container.get(Environment);
const envLoader = await loadModule(this.config.loaders.env);
env.process(envLoader);
}
Expand Down Expand Up @@ -59,7 +59,7 @@ class AppBootstrap {
private async loadEntrypoint(): Promise<void> {
if (this.config.entrypoint) {
const entrypoint = await loadModule(this.config.entrypoint);
entrypoint();
await entrypoint();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/hono-openapi-adapter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cosmoosjs/hono-openapi",
"version": "1.1.1",
"version": "1.1.4",
"description": "Http server using hono zod for @cosmoosjs/core",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
Empty file.
3 changes: 1 addition & 2 deletions packages/hono-openapi-adapter/src/decorators/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './parameter.decorator';
export * from './controller.decorator';
export * from './guard.decorator';
export * from './parameter.decorator';
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function controllerHandler(options: RouteParameters, requestType: RequestMethod,
const route = createRoute(finalRouteMetadata);

if (guards && guards.length > 0) {
guardMiddleware(guards, requestType, finalRouteMetadata.path);
guardMiddleware(guards, requestType, route.getRoutingPath());
}

const openapi = server.hono.openapi(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { SERVER, SERVER_TARGET } from 'src/constants/reflector.constant';
import { guardHandler } from 'src/decorators';
import { RequestMethod } from 'src/enums/request-method';
import type { Server } from 'src/server';
import { serializeRoutePath } from 'src/utils/utils';

/**
* Set middleware for path and method
Expand All @@ -12,7 +11,7 @@ export function guardMiddleware(guards: GuardsType[], requestType: RequestMethod
if (guards && guards.length > 0) {
const middlewareDefinition = getMiddlewareByDefinition(requestType);
if (middlewareDefinition) {
middlewareDefinition(serializeRoutePath(path), async (ctx, next) => {
middlewareDefinition(path, async (ctx, next) => {
guardHandler(guards, ctx);
await next();
});
Expand Down
3 changes: 1 addition & 2 deletions packages/hono-openapi-adapter/src/server/server.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { OpenAPIHono } from '@hono/zod-openapi';
import type { Env } from 'hono';
import { injectable } from 'inversify';

@injectable()
export class Server {
private _hono = new OpenAPIHono();

get hono(): OpenAPIHono<Env, {}, '/'> {
get hono() {
return this._hono;
}
}
19 changes: 0 additions & 19 deletions packages/hono-openapi-adapter/src/utils/utils.spec.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/hono-openapi-adapter/src/utils/utils.ts

This file was deleted.