Skip to content

Commit

Permalink
feat: merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
GGICE committed Jul 4, 2021
2 parents 1fdbd8f + 94a670c commit 5279958
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 23 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [0.0.9] - 2021-07-04

### Added
- Supports setting project config.ts location via 'TY_CONFIG' environment variable

- Supports setting project config.ts location via 'TY_CONFIG' environment
variable
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Deno-based service engine for fast start of server-side development
## Installation

```shell
deno install -A -f --unstable -c tsconfig.json https://deno.land/x/trypoxylus@v0.0.3/bin/trypoxylus.ts
deno install -Af https://deno.land/x/trypoxylus/bin/trypoxylus.ts
```

## Write project code
Expand Down
2 changes: 1 addition & 1 deletion README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
## 安装

```shell
deno install -A -f --unstable -c tsconfig.json https://deno.land/x/trypoxylus@v0.0.3/bin/trypoxylus.ts
deno install -Af https://deno.land/x/trypoxylus/bin/trypoxylus.ts
```

## 编写项目代码
Expand Down
8 changes: 8 additions & 0 deletions demo/controllers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Context } from "https://deno.land/x/oak/mod.ts";

export const controller = {
router: "/",
get: (ctx: Context) => {
ctx.response.body = "index page";
},
};
4 changes: 1 addition & 3 deletions src/common/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Model } from "https://deno.land/x/denodb/mod.ts";
import { Context } from "https://deno.land/x/oak/mod.ts";
import { CorsOptions } from "https://deno.land/x/cors/mod.ts";
import { Context, CorsOptions, Model } from "../deps.ts";

export interface ICtrl {
router: string;
Expand Down
16 changes: 16 additions & 0 deletions src/deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* `std` dependencies
*/
import * as path from "https://deno.land/std/path/mod.ts";

export { path };

/**
* 3rd party dependencies
*/
export { Application, Context, Router } from "https://deno.land/x/oak/mod.ts";
export { oakCors } from "https://deno.land/x/cors/mod.ts";
export { Database, Model } from "https://deno.land/x/denodb/mod.ts";
export { ld } from "https://deno.land/x/deno_lodash/mod.ts";

export type { CorsOptions } from "https://deno.land/x/cors/mod.ts";
3 changes: 1 addition & 2 deletions src/middleware-manager/mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Application } from "https://deno.land/x/oak/mod.ts";
import * as path from "https://deno.land/std/path/mod.ts";
import { Application, path } from "../deps.ts";
import { isIgnoreError } from "../utils/mod.ts";

export async function initMiddleware(app: Application, appPath: string) {
Expand Down
3 changes: 1 addition & 2 deletions src/mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
import { oakCors } from "https://deno.land/x/cors/mod.ts";
import { Application, oakCors, Router } from "./deps.ts";
import { initModel } from "./model-manager/mod.ts";
import { initRouters } from "./router-manager/mod.ts";
import { getConfig } from "./utils/configer.ts";
Expand Down
6 changes: 2 additions & 4 deletions src/model-manager/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Application } from "https://deno.land/x/oak/mod.ts";
import * as path from "https://deno.land/std/path/mod.ts";
import { Database } from "https://deno.land/x/denodb/mod.ts";
import { Application, Database, path } from "../deps.ts";
import { getConfig } from "../utils/configer.ts";
import { isIgnoreError } from "../utils/mod.ts";

Expand All @@ -23,7 +21,7 @@ export async function initModel(app: Application, appPath: string) {
const modelPath = path.join(appPath, "models");

app.state.models = app.state.models || {};
let list = [];
const list = [];
for (const file of Deno.readDirSync(modelPath)) {
if (!file || !file.name) {
continue;
Expand Down
10 changes: 2 additions & 8 deletions src/router-manager/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
import { ld } from "https://deno.land/x/deno_lodash/mod.ts";
import * as path from "https://deno.land/std/path/mod.ts";
import { Application, ld, path, Router } from "../deps.ts";
import { ICtrl } from "../common/mod.ts";
import { isIgnoreError } from "../utils/mod.ts";

Expand All @@ -15,11 +13,7 @@ const SUPPORT_METHOD_LIST = [
"all",
];

export function initRouters(
app: Application,
router: Router,
appPath: string,
) {
export function initRouters(app: Application, router: Router, appPath: string) {
try {
const routerPath = path.join(appPath, "controllers");

Expand Down
2 changes: 1 addition & 1 deletion src/utils/configer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from "https://deno.land/std/path/mod.ts";
import { path } from "../deps.ts";
import { Iconfig } from "../common/mod.ts";

let config: Iconfig;
Expand Down
1 change: 1 addition & 0 deletions src/utils/mod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// deno-lint-ignore no-explicit-any
export function isIgnoreError(error: any) {
if (error.toString().indexOf("No such file or directory") !== -1) {
return true;
Expand Down

0 comments on commit 5279958

Please sign in to comment.