-
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #641 from samchon/features/clone
Fix #639 - clone mode for native class (`Date`) types
- Loading branch information
Showing
24 changed files
with
454 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { INestiaConfig } from "@nestia/sdk"; | ||
|
||
export const NESTIA_CONFIG: INestiaConfig = { | ||
input: ["src/controllers"], | ||
output: "src/api", | ||
e2e: "src/test", | ||
clone: true, | ||
swagger: { | ||
output: "swagger.json", | ||
security: { | ||
bearer: { | ||
type: "apiKey", | ||
}, | ||
}, | ||
}, | ||
}; | ||
export default NESTIA_CONFIG; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { INestApplication } from "@nestjs/common"; | ||
import { NestFactory } from "@nestjs/core"; | ||
|
||
import core from "@nestia/core"; | ||
|
||
export class Backend { | ||
private application_?: INestApplication; | ||
|
||
public async open(): Promise<void> { | ||
this.application_ = await NestFactory.create( | ||
await core.EncryptedModule.dynamic(__dirname + "/controllers", { | ||
key: "A".repeat(32), | ||
iv: "B".repeat(16), | ||
}), | ||
{ logger: false }, | ||
); | ||
await this.application_.listen(37_000); | ||
} | ||
|
||
public async close(): Promise<void> { | ||
if (this.application_ === undefined) return; | ||
|
||
const app = this.application_; | ||
await app.close(); | ||
|
||
delete this.application_; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { HttpError } from "@nestia/fetcher"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type { IConnection } from "@nestia/fetcher"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type { Primitive } from "@nestia/fetcher"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module api.functional.date | ||
* @nestia Generated by Nestia - https://github.com/samchon/nestia | ||
*/ | ||
//================================================================ | ||
import type { IConnection, Primitive } from "@nestia/fetcher"; | ||
import { PlainFetcher } from "@nestia/fetcher/lib/PlainFetcher"; | ||
|
||
import type { IDateDefined } from "../../structures/IDateDefined"; | ||
|
||
/** | ||
* @controller DateController.get | ||
* @path GET /date | ||
* @nestia Generated by Nestia - https://github.com/samchon/nestia | ||
*/ | ||
export async function get( | ||
connection: IConnection, | ||
): Promise<get.Output> { | ||
return PlainFetcher.fetch( | ||
connection, | ||
{ | ||
...get.METADATA, | ||
path: get.path(), | ||
} as const, | ||
); | ||
} | ||
export namespace get { | ||
export type Output = Primitive<IDateDefined>; | ||
|
||
export const METADATA = { | ||
method: "GET", | ||
path: "/date", | ||
request: null, | ||
response: { | ||
type: "application/json", | ||
encrypted: false, | ||
}, | ||
status: null, | ||
} as const; | ||
|
||
export const path = (): string => { | ||
return `/date`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* @packageDocumentation | ||
* @module api.functional | ||
* @nestia Generated by Nestia - https://github.com/samchon/nestia | ||
*/ | ||
//================================================================ | ||
export * as date from "./date"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import * as api from "./module"; | ||
|
||
export * from "./module"; | ||
export default api; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export type * from "./IConnection"; | ||
export type * from "./Primitive"; | ||
export * from "./HttpError"; | ||
|
||
export * as functional from "./functional"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type ArrayBufferLike = ArrayBuffer | SharedArrayBuffer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { Format } from "typia/lib/tags/Format"; | ||
|
||
export type IDateDefined = { | ||
string: (string & Format<"date-time">); | ||
date: (string & Format<"date-time">); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export type __type = { | ||
type: ("Buffer"); | ||
data: Array<number>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { ArrayBufferLike } from "./ArrayBufferLike"; | ||
|
||
export namespace buffer { | ||
export namespace global { | ||
export type Buffer = { | ||
/** | ||
* The size in bytes of each element in the array. | ||
*/ | ||
BYTES_PER_ELEMENT: number; | ||
/** | ||
* The ArrayBuffer instance referenced by the array. | ||
*/ | ||
buffer: ArrayBufferLike; | ||
/** | ||
* The length in bytes of the array. | ||
*/ | ||
byteLength: number; | ||
/** | ||
* The offset in bytes of the array. | ||
*/ | ||
byteOffset: number; | ||
/** | ||
* The length of the array. | ||
*/ | ||
length: number; | ||
"__@toStringTag@398": ("Uint8Array"); | ||
} & { | ||
[key: number]: number; | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
test/features/clone-date/src/controllers/DateController.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import core from "@nestia/core"; | ||
import { Controller } from "@nestjs/common"; | ||
|
||
@Controller("date") | ||
export class DateController { | ||
@core.TypedRoute.Get() | ||
public get(): IDateDefined { | ||
return { | ||
string: new Date().toISOString(), | ||
date: new Date(), | ||
}; | ||
} | ||
} | ||
|
||
interface IDateDefined { | ||
/** | ||
* @format date-time | ||
*/ | ||
string: string; | ||
|
||
date: Date; | ||
} |
12 changes: 12 additions & 0 deletions
12
test/features/clone-date/src/test/features/api/automated/test_api_date_get.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import typia from "typia"; | ||
|
||
import api from "../../../../api"; | ||
|
||
export const test_api_date_get = async ( | ||
connection: api.IConnection | ||
): Promise<void> => { | ||
const output = await api.functional.date.get( | ||
connection, | ||
); | ||
typia.assert(output); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { DynamicExecutor } from "@nestia/e2e"; | ||
|
||
import { Backend } from "../Backend"; | ||
|
||
async function main(): Promise<void> { | ||
const server: Backend = new Backend(); | ||
await server.open(); | ||
|
||
const report: DynamicExecutor.IReport = await DynamicExecutor.validate({ | ||
extension: __filename.substring(__filename.length - 2), | ||
prefix: "test", | ||
parameters: () => [ | ||
{ | ||
host: "http://127.0.0.1:37000", | ||
encryption: { | ||
key: "A".repeat(32), | ||
iv: "B".repeat(16), | ||
}, | ||
}, | ||
], | ||
})(`${__dirname}/features`); | ||
await server.close(); | ||
|
||
const exceptions: Error[] = report.executions | ||
.filter((exec) => exec.error !== null) | ||
.map((exec) => exec.error!); | ||
if (exceptions.length === 0) { | ||
console.log("Success"); | ||
console.log("Elapsed time", report.time.toLocaleString(), `ms`); | ||
} else { | ||
for (const exp of exceptions) console.log(exp); | ||
console.log("Failed"); | ||
console.log("Elapsed time", report.time.toLocaleString(), `ms`); | ||
process.exit(-1); | ||
} | ||
} | ||
main().catch((exp) => { | ||
console.log(exp); | ||
process.exit(-1); | ||
}); |
Oops, something went wrong.