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

fix: replace __dirname by his esm equivalent syntax #2838

Closed
wants to merge 6 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 0 additions & 14 deletions .eslintignore

This file was deleted.

37 changes: 0 additions & 37 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ tools/**/dist
.db
**/keys/jwks.json
/packages/prisma/test/prisma/generated
tsconfig.*.tsbuildinfo

# Website
/docs/api
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/bin/benchmark-bench.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";
import {Command} from "commander";
import inquirer from "inquirer";

import bench from "../src/bench.js";
import {choices, list} from "../src/packages.js";
import {Command} from "commander";

const program = new Command();

Expand Down
11 changes: 6 additions & 5 deletions benchmarks/bin/benchmark-compare.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/usr/bin/env node
import os from "os";
import chalk from "chalk";
import Table from "cli-table";
import {Command} from "commander";
import {readdirSync, readFileSync, writeFileSync} from "fs";
import inquirer from "inquirer";
import Table from "cli-table";
import chalk from "chalk";
import os from "os";
import {join} from "path";
import {readdirSync, readFileSync, writeFileSync} from "fs";
import {info} from "../src/packages.js";

import {compare} from "../src/autocannon.js";
import {info} from "../src/packages.js";

const commander = new Command();

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/frameworks/express-injector-async-hook.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import express from "express";
import {InjectorService} from "@tsed/di";
import {PlatformContext, PlatformRequest, PlatformResponse} from "@tsed/common";
import {InjectorService} from "@tsed/di";
import express from "express";
import {v4} from "uuid";

const app = express();
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/frameworks/express-injector-http-hook.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import express from "express";
import {InjectorService, runInContext, setContext} from "@tsed/di";
import {PlatformContext, PlatformRequest, PlatformResponse} from "@tsed/common";
import {v4} from "uuid";
import {InjectorService, runInContext, setContext} from "@tsed/di";
import express from "express";
import http from "http";
import {v4} from "uuid";

const injector = new InjectorService();
const app = express();
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/frameworks/express-injector-without-events.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import express from "express";
import {InjectorService, runInContext, setContext} from "@tsed/di";
import {PlatformContext, PlatformRequest, PlatformResponse} from "@tsed/common";
import {v4} from "uuid";
import {InjectorService, runInContext, setContext} from "@tsed/di";
import express from "express";
import http from "http";
import {v4} from "uuid";

const injector = new InjectorService();
const app = express();
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/frameworks/express-injector.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import express from "express";
import {InjectorService} from "@tsed/di";
import {PlatformContext, PlatformRequest, PlatformResponse} from "@tsed/common";
import {InjectorService} from "@tsed/di";
import express from "express";
import {v4} from "uuid";

const app = express();
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/frameworks/fastify-injector.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Fastify from "fastify";
import {InjectorService, runInContext, getContext} from "@tsed/di";
import {PlatformContext} from "@tsed/common";
import {getContext, InjectorService, runInContext} from "@tsed/di";
import Fastify from "fastify";
import {v4} from "uuid";

const fastify = Fastify();
Expand Down
1 change: 1 addition & 0 deletions benchmarks/frameworks/hapi.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "make-promises-safe";

import Hapi from "@hapi/hapi";

async function start() {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/frameworks/koa-isomorphic-router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Koa from "koa";
import Router from "benchmarks/frameworks/koa-isomorphic-router.js";
import Koa from "koa";

const app = new Koa();
const router = new Router();
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/frameworks/koa-router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Koa from "koa";
import KoaRouter from "benchmarks/frameworks/koa-router.js";
import Koa from "koa";

const router = KoaRouter();

Expand Down
1 change: 1 addition & 0 deletions benchmarks/frameworks/nest-fastify.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import core from "@nestjs/core";
import fastifyPlatform from "@nestjs/platform-fastify";

import {AppModule} from "./nest/app/app.module.js";

core.NestFactory.create(AppModule, new fastifyPlatform.FastifyAdapter(), {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/frameworks/nest/app/app.controller.js

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

3 changes: 2 additions & 1 deletion benchmarks/frameworks/nest/app/app.module.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {__decorate} from "tslib";
import common_1 from "@nestjs/common";
import {__decorate} from "tslib";

import {AppController} from "./app.controller.js";

class AppModule {}
Expand Down
1 change: 1 addition & 0 deletions benchmarks/frameworks/nest/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
import core from "@nestjs/core";

import {AppModule} from "./app/app.module.js";

core.NestFactory.create(AppModule, {
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/frameworks/tsed-express.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict";
import {PlatformApplication} from "@tsed/common";
import {Inject} from "@tsed/di";
import {PlatformExpress} from "@tsed/platform-express";
import {__decorate} from "tslib";
import {Inject} from "@tsed/di";
import {PlatformApplication} from "@tsed/common";

class Server {
$onInit() {
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/frameworks/tsed-koa.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict";
import {PlatformApplication} from "@tsed/common";
import {Inject} from "@tsed/di";
import {PlatformKoa} from "@tsed/platform-koa";
import {__decorate} from "tslib";
import {Inject} from "@tsed/di";
import {PlatformApplication} from "@tsed/common";

class Server {
$beforeRoutesInit() {
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/frameworks/tsed-no-context.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict";
import {PlatformApplication} from "@tsed/common";
import {Inject} from "@tsed/di";
import {PlatformExpress} from "@tsed/platform-express";
import {__decorate} from "tslib";
import {Inject} from "@tsed/di";
import {PlatformApplication} from "@tsed/common";

class Server {
$onInit() {
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/frameworks/tsed-no-events.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict";
import {PlatformApplication} from "@tsed/common";
import {Inject} from "@tsed/di";
import {PlatformExpress} from "@tsed/platform-express";
import {__decorate} from "tslib";
import {Inject} from "@tsed/di";
import {PlatformApplication} from "@tsed/common";

class Server {
$onInit() {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/autocannon.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import autocannon from "autocannon";
import fs from "fs";
import autoCompare from "autocannon-compare";
import fs from "fs";
import path from "path";
import {promisify} from "util";

Expand Down
3 changes: 2 additions & 1 deletion benchmarks/src/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import {execa} from "execa";
import ora from "ora";
import path from "path";
import {fire} from "./autocannon.js";
import {fileURLToPath} from "url";

import {fire} from "./autocannon.js";

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const doBench = async (opts, handler) => {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/packages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from "fs";
import {dirname, join} from "path";
import {createRequire} from "module";
import {dirname, join} from "path";

const require = createRequire(import.meta.url);

Expand Down
3 changes: 2 additions & 1 deletion docs/.vuepress/enhanceApp.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import "./window-boot.js";
import VueTsED from "vuepress-theme-tsed/src/install";
import "./styles/style.css";
import "prismjs/components/prism-groovy";

import VueTsED from "vuepress-theme-tsed/src/install";

export default ({
Vue, // the version of Vue being used in the VuePress app
options, // the options for the root Vue instance
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Get} from "@tsed/schema";
import {Controller} from "@tsed/di";
import {Get} from "@tsed/schema";

import {CustomAuth} from "../decorators/CustomAuth";

@Controller("/dashboard")
Expand Down
5 changes: 3 additions & 2 deletions docs/docs/snippets/authentication/auth-decorator-example-2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {In, Returns, Security} from "@tsed/schema";
import {UseAuth} from "@tsed/platform-middlewares";
import {useDecorators} from "@tsed/core";
import {UseAuth} from "@tsed/platform-middlewares";
import {In, Returns, Security} from "@tsed/schema";

import {CustomAuthMiddleware} from "../guards/CustomAuthMiddleware";

export interface CustomAuthOptions extends Record<string, unknown> {
Expand Down
5 changes: 3 additions & 2 deletions docs/docs/snippets/authentication/auth-decorator-example.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {UseAuth} from "@tsed/platform-middlewares";
import {useDecorators} from "@tsed/core";
import {Security, Returns} from "@tsed/schema";
import {UseAuth} from "@tsed/platform-middlewares";
import {Returns, Security} from "@tsed/schema";

import {CustomAuthMiddleware} from "../guards/CustomAuthMiddleware";

export interface AuthOpts extends Record<string, unknown> {
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/snippets/authentication/auth-example.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Controller} from "@tsed/di";
import {Get} from "@tsed/schema";
import {UseAuth} from "@tsed/platform-middlewares";
import {Get} from "@tsed/schema";

import {CustomAuthMiddleware} from "../guards/CustomAuthMiddleware";

@Controller("/dashboard")
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/snippets/authentication/auth-middleware.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Req} from "@tsed/common";
import {Context} from "@tsed/platform-params";
import {Middleware, MiddlewareMethods} from "@tsed/platform-middlewares";
import {Forbidden, Unauthorized} from "@tsed/exceptions";
import {Middleware, MiddlewareMethods} from "@tsed/platform-middlewares";
import {Context} from "@tsed/platform-params";

@Middleware()
export class CustomAuthMiddleware implements MiddlewareMethods {
Expand Down
9 changes: 5 additions & 4 deletions docs/docs/snippets/authentication/auth-swagger-example.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {Controller} from "@tsed/di";
import {Get, Returns, Security} from "@tsed/schema";
import {UseAuth} from "@tsed/platform-middlewares";
import {Forbidden, Unauthorized} from "@tsed/exceptions";
import {UseAuth} from "@tsed/platform-middlewares";
import {Get, Returns, Security} from "@tsed/schema";

import {CustomAuthMiddleware} from "../guards/CustomAuthMiddleware";

@Controller("/dashboard")
Expand All @@ -11,7 +12,7 @@ class DashboardCtrl {
@Get("/")
@UseAuth(CustomAuthMiddleware, {role: "admin"}) // or for specific endpoints
@Security("oauth2", "email", "firstname")
@Returns(401, Unauthorized).Description("Unauthorized")
@Returns(403, Forbidden).Description("Forbidden")
@(Returns(401, Unauthorized).Description("Unauthorized"))
@(Returns(403, Forbidden).Description("Forbidden"))
public getResource() {}
}
1 change: 1 addition & 0 deletions docs/docs/snippets/configuration/bootstrap-with-dotenv.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {$log} from "@tsed/common";
import {PlatformExpress} from "@tsed/platform-express";

import {Server} from "./server";

const config = require("dotenv").config({path: "/full/custom/path/to/your/env/vars"});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {$log} from "@tsed/common";
import {PlatformExpress} from "@tsed/platform-express";

import {Server} from "./server";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

// /!\ configuration file must be outside of your src directory
process.env["NODE_CONFIG_DIR"] = `${rootDir}/../config`;
Expand Down
1 change: 1 addition & 0 deletions docs/docs/snippets/configuration/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {$log} from "@tsed/common";
import {PlatformExpress} from "@tsed/platform-express";

import {Server} from "./server";

async function bootstrap() {
Expand Down
1 change: 1 addition & 0 deletions docs/docs/snippets/configuration/module-options-imports.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Module} from "@tsed/di";

import {MyController} from "./controllers/MyController";
import {MyService} from "./services/MyService";

Expand Down
1 change: 1 addition & 0 deletions docs/docs/snippets/configuration/module-resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Module} from "@tsed/di";

import {myContainer} from "./inversify.config";

@Module({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Module} from "@tsed/di";

import {UserController} from "./users/UserController";

@Module({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Module} from "@tsed/di";

import {UserController} from "./users/UserController";

@Module({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Configuration} from "@tsed/di";

import {ModuleV0} from "./v0/ModuleV0";
import {ModuleV1} from "./v1/ModuleV1";

Expand Down
Loading
Loading