Skip to content

Commit

Permalink
Merge pull request #114 from norflin321/absolute-imports
Browse files Browse the repository at this point in the history
configure absolute imports
  • Loading branch information
santiq authored Aug 16, 2021
2 parents 7b747ae + 09483b4 commit 38789d0
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/api/middlewares/attachCurrentUser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Container } from 'typedi';
import mongoose from 'mongoose';
import { IUser } from '../../interfaces/IUser';
import { IUser } from '@/interfaces/IUser';
import { Logger } from 'winston';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/api/middlewares/isAuth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import jwt from 'express-jwt';
import config from '../../config';
import config from '@/config';

/**
* We are assuming that the JWT will come in a header with the form
Expand Down
2 changes: 1 addition & 1 deletion src/api/routes/agendash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Router } from 'express'
import basicAuth from 'express-basic-auth';
import agendash from 'agendash'
import { Container } from 'typedi'
import config from '../../config'
import config from '@/config'

export default (app: Router) => {

Expand Down
4 changes: 2 additions & 2 deletions src/api/routes/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Router, Request, Response, NextFunction } from 'express';
import { Container } from 'typedi';
import AuthService from '../../services/auth';
import { IUserInputDTO } from '../../interfaces/IUser';
import AuthService from '@/services/auth';
import { IUserInputDTO } from '@/interfaces/IUser';
import middlewares from '../middlewares';
import { celebrate, Joi } from 'celebrate';
import { Logger } from 'winston';
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/emailSequence.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Container } from 'typedi';
import MailerService from '../services/mailer';
import MailerService from '@/services/mailer';
import { Logger } from 'winston';

export default class EmailSequenceJob {
Expand Down
2 changes: 1 addition & 1 deletion src/loaders/agenda.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Agenda from 'agenda';
import config from '../config';
import config from '@/config';

export default ({ mongoConnection }) => {
return new Agenda({
Expand Down
2 changes: 1 addition & 1 deletion src/loaders/dependencyInjector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import formData from 'form-data';
import Mailgun from 'mailgun.js';
import LoggerInstance from './logger';
import agendaFactory from './agenda';
import config from '../config';
import config from '@/config';

export default ({ mongoConnection, models }: { mongoConnection; models: { name: string; model: any }[] }) => {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/loaders/events.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
//Here we import all events
import '../subscribers/user';
import '@/subscribers/user';
4 changes: 2 additions & 2 deletions src/loaders/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import express from 'express';
import bodyParser from 'body-parser';
import cors from 'cors';
import { OpticMiddleware } from '@useoptic/express-middleware';
import routes from '../api';
import config from '../config';
import routes from '@/api';
import config from '@/config';
export default ({ app }: { app: express.Application }) => {
/**
* Health Check endpoints
Expand Down
4 changes: 2 additions & 2 deletions src/loaders/jobs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import config from '../config';
import EmailSequenceJob from '../jobs/emailSequence';
import config from '@/config';
import EmailSequenceJob from '@/jobs/emailSequence';
import Agenda from 'agenda';

export default ({ agenda }: { agenda: Agenda }) => {
Expand Down
4 changes: 2 additions & 2 deletions src/loaders/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import winston from 'winston';
import config from '../config';
import config from '@/config';

const transports = [];
if(process.env.NODE_ENV !== 'development') {
Expand Down Expand Up @@ -31,4 +31,4 @@ const LoggerInstance = winston.createLogger({
transports
});

export default LoggerInstance;
export default LoggerInstance;
2 changes: 1 addition & 1 deletion src/loaders/mongoose.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import mongoose from 'mongoose';
import { Db } from 'mongodb';
import config from '../config';
import config from '@/config';

export default async (): Promise<Db> => {
const connection = await mongoose.connect(config.databaseURL, {
Expand Down
2 changes: 1 addition & 1 deletion src/models/user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IUser } from '../interfaces/IUser';
import { IUser } from '@/interfaces/IUser';
import mongoose from 'mongoose';

const User = new mongoose.Schema(
Expand Down
8 changes: 4 additions & 4 deletions src/services/auth.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Service, Inject } from 'typedi';
import jwt from 'jsonwebtoken';
import MailerService from './mailer';
import config from '../config';
import config from '@/config';
import argon2 from 'argon2';
import { randomBytes } from 'crypto';
import { IUser, IUserInputDTO } from '../interfaces/IUser';
import { EventDispatcher, EventDispatcherInterface } from '../decorators/eventDispatcher';
import events from '../subscribers/events';
import { IUser, IUserInputDTO } from '@/interfaces/IUser';
import { EventDispatcher, EventDispatcherInterface } from '@/decorators/eventDispatcher';
import events from '@/subscribers/events';

@Service()
export default class AuthService {
Expand Down
2 changes: 1 addition & 1 deletion src/services/mailer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Service, Inject } from 'typedi';
import { IUser } from '../interfaces/IUser';
import { IUser } from '@/interfaces/IUser';

@Service()
export default class MailerService {
Expand Down
2 changes: 1 addition & 1 deletion src/subscribers/user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Container } from 'typedi';
import { EventSubscriber, On } from 'event-dispatch';
import events from './events';
import { IUser } from '../interfaces/IUser';
import { IUser } from '@/interfaces/IUser';
import mongoose from 'mongoose';
import { Logger } from 'winston';

Expand Down
2 changes: 1 addition & 1 deletion src/types/express/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Document, Model } from 'mongoose';
import { IUser } from '../../interfaces/IUser';
import { IUser } from '@/interfaces/IUser';
declare global {
namespace Express {
export interface Request {
Expand Down
8 changes: 6 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"outDir": "./build",
"allowJs": true,
"noEmit": false,
"esModuleInterop": true
"esModuleInterop": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": [
"./src/**/*"
Expand All @@ -29,4 +33,4 @@
"node_modules",
"tests"
]
}
}

0 comments on commit 38789d0

Please sign in to comment.