Skip to content

Commit

Permalink
Merge pull request #9 from Savory/jsr
Browse files Browse the repository at this point in the history
feat: migrate to JSR
  • Loading branch information
Sorikairox authored Nov 7, 2024
2 parents ef0241e + 5d5cf44 commit f82583c
Show file tree
Hide file tree
Showing 17 changed files with 246 additions and 32 deletions.
6 changes: 5 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"name": "",
"version": "",
"lint": {
"rules": {
"exclude": ["require-await"]
"exclude": [
"require-await"
]
}
},
"fmt": {
Expand Down
207 changes: 207 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions import_map.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"imports": {
"danet/": "https://deno.land/x/danet/",
"dotenv/": "https://deno.land/[email protected]/dotenv/",
"mongo/": "https://deno.land/x/[email protected]/",
"postgres/": "https://deno.land/x/[email protected]/",
"danet_swagger/": "https://deno.land/x/danet_swagger/"
"@danet/core": "jsr:@danet/[email protected]",
"@std/dotenv": "jsr:@std/[email protected]",
"@db/mongo": "jsr:@db/[email protected]",
"@bartlomieju/postgres": "jsr:@bartlomieju/postgres",
"@danet/swagger": "jsr:@danet/swagger@2",
"@std/assert": "jsr:@std/[email protected]",
"@std/testing": "jsr:@std/[email protected]"
}
}
6 changes: 3 additions & 3 deletions spec/todo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import {
beforeAll,
describe,
it,
} from 'https://deno.land/[email protected]/testing/bdd.ts';
} from '@std/testing/bdd';
import {
assertArrayIncludes,
assertEquals,
assertExists,
} from 'https://deno.land/[email protected]/testing/asserts.ts';
} from '@std/assert';
import { Todo } from '../src/todo/class.ts';
import { TodoService } from '../src/todo/service.ts';
import { DanetApplication } from 'danet/mod.ts';
import { DanetApplication } from '@danet/core';

let app: DanetApplication;
let server;
Expand Down
2 changes: 1 addition & 1 deletion src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Get } from 'danet/mod.ts';
import { Controller, Get } from '@danet/core';

@Controller('')
export class AppController {
Expand Down
2 changes: 1 addition & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Module } from 'danet/mod.ts';
import { Module } from '@danet/core';
import { TodoModule } from './todo/module.ts';
import { AppController } from './app.controller.ts';

Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dotenv/load.ts';
import '@std/dotenv';
import { AppModule } from './app.module.ts';
import { DanetApplication } from 'danet/mod.ts';
import { DanetApplication } from '@danet/core';
import { loggerMiddleware } from './logger.middleware.ts';
import { SpecBuilder, SwaggerModule } from 'danet_swagger/mod.ts';
import { SpecBuilder, SwaggerModule } from '@danet/swagger';
export const bootstrap = async () => {
const application = new DanetApplication();
await application.init(AppModule);
Expand Down
2 changes: 1 addition & 1 deletion src/database/module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Module, TokenInjector } from 'danet/mod.ts';
import { Module, TokenInjector } from '@danet/core';
import { PostgresService } from './postgres.service.ts';

export const DATABASE = 'DATABASE';
Expand Down
8 changes: 4 additions & 4 deletions src/database/mongodb.service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Injectable } from 'danet/mod.ts';
import { OnAppBootstrap, OnAppClose } from 'danet/src/hook/interfaces.ts';
import { Collection, Database, MongoClient } from 'mongo/mod.ts';
import { Injectable } from '@danet/core';
import { OnAppBootstrap, OnAppClose } from '@danet/core/hook';
import { Collection, Database, MongoClient, Document } from '@db/mongo';

@Injectable()
export class MongodbService implements OnAppBootstrap, OnAppClose {
constructor() {}

private client = new MongoClient();
private db!: Database;
getCollection<T>(collectionName: string): Collection<T> {
getCollection<T extends Document>(collectionName: string): Collection<T> {
return this.db.collection(collectionName);
}

Expand Down
6 changes: 3 additions & 3 deletions src/database/postgres.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from 'danet/mod.ts';
import { OnAppBootstrap, OnAppClose } from 'danet/src/hook/interfaces.ts';
import { Client } from 'postgres/mod.ts';
import { Injectable } from '@danet/core';
import { OnAppBootstrap, OnAppClose } from '@danet/core/hook';
import { Client } from '@bartlomieju/postgres';

@Injectable()
export class PostgresService implements OnAppBootstrap, OnAppClose {
Expand Down
2 changes: 1 addition & 1 deletion src/logger.middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpContext, Logger, NextFunction } from 'danet/mod.ts';
import { HttpContext, Logger, NextFunction } from '@danet/core';

const logger = new Logger('Logger');

Expand Down
5 changes: 3 additions & 2 deletions src/todo/class.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { IsString, LengthGreater } from 'danet/validation.ts';
import { IsString, LengthGreater } from '@danet/core/validation';
import type { ObjectId } from '@db/mongo';

export class Todo {
readonly _id = crypto.randomUUID();
readonly _id: `${string}-${string}-${string}-${string}-${string}` | ObjectId = crypto.randomUUID();
@IsString()
public title: string;

Expand Down
4 changes: 2 additions & 2 deletions src/todo/controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Body, Controller, Delete, Get, Param, Post, Put } from 'danet/mod.ts';
import { Body, Controller, Delete, Get, Param, Post, Put } from '@danet/core';
import { Todo } from './class.ts';
import { TodoService } from './service.ts';
import { ReturnedType } from 'danet_swagger/decorators.ts';
import { ReturnedType } from '@danet/swagger/decorators';

@Controller('todo')
export class TodoController {
Expand Down
2 changes: 1 addition & 1 deletion src/todo/module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TodoController } from './controller.ts';
import { TodoService } from './service.ts';
import { Module, TokenInjector } from 'danet/mod.ts';
import { Module, TokenInjector } from '@danet/core';
import { USER_REPOSITORY } from './constant.ts';
import { InMemoryTodoRepository } from './in-memory-repository.ts';

Expand Down
4 changes: 2 additions & 2 deletions src/todo/mongodb-repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Repository } from '../database/repository.ts';
import { Todo } from './class.ts';
import { ObjectId } from 'mongo/mod.ts';
import { Inject } from 'danet/mod.ts';
import { ObjectId } from '@db/mongo';
import { Inject } from '@danet/core';
import { DATABASE } from '../database/module.ts';
import { MongodbService } from '../database/mongodb.service.ts';

Expand Down
2 changes: 1 addition & 1 deletion src/todo/postgres-repository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Repository } from '../database/repository.ts';
import { Todo } from './class.ts';
import { Inject } from 'danet/mod.ts';
import { Inject } from '@danet/core';
import { DATABASE } from '../database/module.ts';
import { PostgresService } from '../database/postgres.service.ts';

Expand Down
2 changes: 1 addition & 1 deletion src/todo/service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Inject, Injectable } from 'danet/mod.ts';
import { Inject, Injectable } from '@danet/core';
import { Todo } from './class.ts';
import type { Repository } from '../database/repository.ts';
import { USER_REPOSITORY } from './constant.ts';
Expand Down

0 comments on commit f82583c

Please sign in to comment.