Organize imports better

This commit is contained in:
Gender Shrapnel 2019-09-26 20:19:57 +02:00
parent e2bdaf6603
commit b4f707da19
11 changed files with 63 additions and 18 deletions

35
package-lock.json generated
View File

@ -235,6 +235,12 @@
"integrity": "sha512-mzJX3tIbtadNZQIDbfA9eW+mAjww7GY7WYcfKDGB5SSXMAzI8KD+5fvyX5FqcKtns346+WGwAJJ8cPsDxMz0lw==",
"dev": true
},
"@types/json5": {
"version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
"integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=",
"dev": true
},
"@types/keygrip": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@types/keygrip/-/keygrip-1.0.1.tgz",
@ -1492,6 +1498,15 @@
"esprima": "^4.0.0"
}
},
"json5": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
}
},
"leven": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz",
@ -2504,6 +2519,26 @@
}
}
},
"tsconfig-paths": {
"version": "3.9.0",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz",
"integrity": "sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw==",
"dev": true,
"requires": {
"@types/json5": "^0.0.29",
"json5": "^1.0.1",
"minimist": "^1.2.0",
"strip-bom": "^3.0.0"
},
"dependencies": {
"strip-bom": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
"integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=",
"dev": true
}
}
},
"tslib": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz",

View File

@ -6,7 +6,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"tsc": "tsc",
"dev": "ts-node-dev -r dotenv/config --respawn --transpile-only ./src/index.ts",
"dev": "ts-node-dev -r dotenv/config -r tsconfig-paths/register --respawn --transpile-only ./src/index.ts",
"prod": "tsc && node ./dist/index.js",
"tslint-check": "tslint-config-prettier-check ./tslint.json"
},
@ -43,6 +43,7 @@
"@types/pino": "^5.8.10",
"pino-pretty": "^3.2.1",
"ts-node-dev": "^1.0.0-pre.43",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.20.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.6.3"

View File

@ -13,13 +13,12 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import { db } from "@kredens/db";
import { ApolloServer, gql } from "apollo-server-express";
import { Kind } from "graphql/language";
import { GraphQLScalarType, GraphQLScalarTypeConfig } from "graphql/type";
import { DateTime } from "luxon";
import { db } from "./db";
const typeDefs = gql`
type Query {
"A simple type for getting started"

View File

@ -13,8 +13,12 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import {
Extensions,
MigrationRepository,
UserRepository
} from "@kredens/db/repos";
import pgPromise, { IDatabase, IInitOptions } from "pg-promise";
import { Extensions, MigrationRepository, UserRepository } from "./repos";
type ExtendedProtocol = IDatabase<Extensions> & Extensions;

View File

@ -13,8 +13,8 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import { MigrationRepository } from "./migrations";
import { UserRepository } from "./users";
import { MigrationRepository } from "@kredens/db/repos/migrations";
import { UserRepository } from "@kredens/db/repos/users";
export interface Extensions {
migrations: MigrationRepository;

View File

@ -13,11 +13,11 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Migration } from "@kredens/db/models";
import { migrations as sql } from "@kredens/db/sql";
import logger from "@kredens/logger";
import { DateTime } from "luxon";
import { IDatabase, IMain } from "pg-promise";
import logger from "../../logger";
import { Migration } from "../models";
import { migrations as sql } from "../sql";
export class MigrationRepository {
private db: IDatabase<any>;

View File

@ -13,10 +13,10 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import { users as sql } from "@kredens/db/sql";
import argon2 from "argon2";
import { Maybe, None, Some } from "monet";
import { IDatabase, IMain } from "pg-promise";
import { users as sql } from "../sql";
export class UserRepository {
private db: IDatabase<any>;

View File

@ -13,16 +13,16 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import { server as graphqlServer } from "@kredens/api";
import { db } from "@kredens/db";
import logger from "@kredens/logger";
import authRouter from "@kredens/routes/auth";
import indexRouter from "@kredens/routes/index";
import cookieParser from "cookie-parser";
import express from "express";
import pinoExpress from "express-pino-logger";
import helmet from "helmet";
import createHttpError from "http-errors";
import { db } from "./db";
import { server as graphqlServer } from "./graphql";
import logger from "./logger";
import authRouter from "./routes/auth";
import indexRouter from "./routes/index";
async function main() {
await db.tx(async t => {

View File

@ -13,11 +13,11 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import { box, unbox } from "@kredens/crypto";
import { db } from "@kredens/db";
import express from "express";
import createHttpError from "http-errors";
import { DateTime } from "luxon";
import { box, unbox } from "../crypto";
import { db } from "../db";
const router = express.Router();

View File

@ -6,6 +6,11 @@
"outDir": "./dist",
"moduleResolution": "node",
"baseUrl": "./src",
"paths": {
"@kredens/*": [
"*"
]
},
"esModuleInterop": true
},
"include": [

View File

@ -7,7 +7,8 @@
"jsRules": {},
"rules": {
"interface-name": [ true, "never-prefix"],
"no-submodule-imports": [true, "graphql/language", "graphql/type"]
"no-submodule-imports": [true, "graphql/language", "graphql/type", "@kredens"],
"no-implicit-dependencies": [true, ["@kredens"]]
},
"rulesDirectory": []
}