Skip to content

Commit

Permalink
refactor: angular
Browse files Browse the repository at this point in the history
  • Loading branch information
radoslavirha committed Sep 29, 2023
1 parent b380fca commit ee8ac41
Show file tree
Hide file tree
Showing 74 changed files with 6,743 additions and 1,787 deletions.
4 changes: 2 additions & 2 deletions api/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"barrels": "barrelsby --config .barrelsby.json",
"start": "pnpm run barrels && tsnd --inspect --exit-child --cls --ignore-watch node_modules --respawn --transpile-only -r tsconfig-paths/register src/index.ts",
"start:prod": "cross-env NODE_ENV=production node dist/index.js",
"format": "eslint --ext .ts --fix .",
"lint": "eslint --ext .ts",
"format": "eslint --ext .ts --fix src",
"lint": "eslint --ext .ts src",
"test": "pnpm run test:coverage",
"test:unit": "cross-env NODE_ENV=test jest",
"test:coverage": "pnpm run test:unit"
Expand Down
2 changes: 1 addition & 1 deletion api/graphql/src/Server.integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PlatformTest } from '@tsed/common';
import { TestMongooseContext } from '@tsed/testing-mongoose';
import SuperTest from 'supertest';
import { Server } from './Server';
import { TestMongooseContext } from '@tsed/testing-mongoose';

describe('Server', () => {
let request: SuperTest.SuperTest<SuperTest.Test>;
Expand Down
12 changes: 6 additions & 6 deletions api/graphql/src/Server.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { join } from 'path';
import { Configuration, Inject } from '@tsed/di';
import '@tsed/ajv';
import { PlatformApplication } from '@tsed/common';
import { Configuration, Inject } from '@tsed/di';
import '@tsed/mongoose';
import '@tsed/platform-express'; // /!\ keep this import
import '@tsed/ajv';
import '@tsed/swagger';
import '@tsed/mongoose';
import '@tsed/typegraphql';
import './resolvers/index';
import { join } from 'path';
import { config } from './config/index';
import * as rest from './controllers/rest/index';
import * as pages from './controllers/pages/index';
import * as rest from './controllers/rest/index';
import './resolvers/index';

@Configuration({
...config,
Expand Down
2 changes: 1 addition & 1 deletion api/graphql/src/controllers/pages/IndexController.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Constant, Controller } from '@tsed/di';
import { HeaderParams } from '@tsed/platform-params';
import { View } from '@tsed/platform-views';
import { Get, Hidden, Returns } from '@tsed/schema';
import { SwaggerSettings } from '@tsed/swagger';
import { Hidden, Get, Returns } from '@tsed/schema';

@Hidden()
@Controller('/')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TestMongooseContext } from '@tsed/testing-mongoose';
import SuperTest from 'supertest';
import { HelloWorldController } from './HelloWorldController';
import { Server } from '../../Server';
import { TestMongooseContext } from '@tsed/testing-mongoose';
import { HelloWorldController } from './HelloWorldController';

describe('HelloWorldController', () => {
let request: SuperTest.SuperTest<SuperTest.Test>;
Expand Down
2 changes: 1 addition & 1 deletion api/graphql/src/models/Comment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Required } from '@tsed/schema';
import { Model, ObjectID, Ref } from '@tsed/mongoose';
import { Required } from '@tsed/schema';
import { Field, ID, InputType, ObjectType } from 'type-graphql';
import { Trip } from './Trip';

Expand Down
2 changes: 1 addition & 1 deletion api/graphql/src/models/Trip.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CollectionOf, Property, Required } from '@tsed/schema';
import { Model, ObjectID, Ref } from '@tsed/mongoose';
import { CollectionOf, Property, Required } from '@tsed/schema';
import { Field, ID, InputType, ObjectType } from 'type-graphql';
import { Comment } from './Comment';

Expand Down
4 changes: 2 additions & 2 deletions api/graphql/src/resolvers/Comment.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TestMongooseContext } from '@tsed/testing-mongoose';
import { TypeGraphQLService } from '@tsed/typegraphql';
import { ApolloServerTestClient, createTestClient } from 'apollo-server-testing';
import gql from 'graphql-tag';
import { Server } from '../Server';
import { CommentService } from '../services/Comment';
import { TestMongooseContext } from '@tsed/testing-mongoose';
import { TypeGraphQLService } from '@tsed/typegraphql';

const GET_TRIP_COMMENTS = gql`
query TripComments($id: String!) {
Expand Down
2 changes: 1 addition & 1 deletion api/graphql/src/resolvers/Comment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject } from '@tsed/di';
import { ResolverController } from '@tsed/typegraphql';
import { Comment } from '../models/Comment';
import { Arg, Query } from 'type-graphql';
import { Comment } from '../models/Comment';
import { CommentService } from '../services/Comment';

@ResolverController()
Expand Down
8 changes: 4 additions & 4 deletions api/graphql/src/resolvers/Trip.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { TestMongooseContext } from '@tsed/testing-mongoose';
import { TypeGraphQLService } from '@tsed/typegraphql';
import { ApolloServerTestClient, createTestClient } from 'apollo-server-testing';
import gql from 'graphql-tag';
import { Server } from '../Server';
import { TripService } from '../services/Trip';
import { TestMongooseContext } from '@tsed/testing-mongoose';
import { TypeGraphQLService } from '@tsed/typegraphql';
import { Trip } from '../models/Trip';
import { TripNotFoundError } from '../errors/TripNotFoundError';
import { Comment } from '../models/Comment';
import { Trip } from '../models/Trip';
import { TripService } from '../services/Trip';

const GET_TRIP = gql`
query Trip($id: String!) {
Expand Down
6 changes: 3 additions & 3 deletions api/graphql/src/resolvers/Trip.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Inject } from '@tsed/di';
import { ResolverController } from '@tsed/typegraphql';
import { Arg, Mutation, Query } from 'type-graphql';
import { TripNotFoundError } from '../errors/TripNotFoundError';
import { AddCommentInput, Comment } from '../models/Comment';
import { AddTripInput, Trip } from '../models/Trip';
import { Arg, Query, Mutation } from 'type-graphql';
import { TripService } from '../services/Trip';
import { TripNotFoundError } from '../errors/TripNotFoundError';
import { Comment, AddCommentInput } from '../models/Comment';

@ResolverController()
export class TripResolver {
Expand Down
4 changes: 2 additions & 2 deletions api/graphql/src/services/Comment.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PlatformTest } from '@tsed/common';
import { CommentService } from './Comment';
import { TestMongooseContext } from '@tsed/testing-mongoose';
import { MongooseModel } from '@tsed/mongoose';
import { TestMongooseContext } from '@tsed/testing-mongoose';
import { Comment } from '../models/Comment';
import { CommentService } from './Comment';

describe('CommentService', () => {
beforeEach(TestMongooseContext.create);
Expand Down
2 changes: 1 addition & 1 deletion api/graphql/src/services/Comment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject, Service } from '@tsed/common';
import { Injectable } from '@tsed/di';
import { MongooseModel } from '@tsed/mongoose';
import { Comment } from '../models/Comment';
import { Injectable } from '@tsed/di';

@Injectable()
@Service()
Expand Down
4 changes: 2 additions & 2 deletions api/graphql/src/services/Trip.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { PlatformTest } from '@tsed/common';
import { TripService } from './Trip';
import { TestMongooseContext } from '@tsed/testing-mongoose';
import { MongooseModel } from '@tsed/mongoose';
import { TestMongooseContext } from '@tsed/testing-mongoose';
import { Comment } from '../models/Comment';
import { Trip } from '../models/Trip';
import { TripService } from './Trip';

describe('TripService', () => {
beforeEach(TestMongooseContext.create);
Expand Down
2 changes: 1 addition & 1 deletion api/graphql/src/services/Trip.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject, Service } from '@tsed/common';
import { MongooseModel } from '@tsed/mongoose';
import { AddCommentInput, Comment } from '../models/Comment';
import { AddTripInput, Trip } from '../models/Trip';
import { Comment, AddCommentInput } from '../models/Comment';

@Service()
export class TripService {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"build": "pnpm --stream -r run build",
"clean": "rm -rf .parcel-cache && pnpm -r run clean",
"lint": "pnpm --stream -r run lint",
"format": "pnpm --stream -r run format",
"test": "pnpm --stream -r run test"
}
}
14 changes: 3 additions & 11 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const prettier = require('./prettier');

module.exports = {
parser: '@typescript-eslint/parser',
extends: [
Expand All @@ -6,22 +8,12 @@ module.exports = {
'plugin:import/typescript',
'plugin:prettier/recommended' // must be last
],
plugins: ['prettier'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
rules: {
'prettier/prettier': [
'error',
{
tabWidth: 2,
semi: true,
singleQuote: true,
trailingComma: 'none',
printWidth: 120
}
],
...prettier,
'import/no-named-as-default': 'off'
},
settings: {
Expand Down
7 changes: 5 additions & 2 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
},
"peerDependencies": {
"eslint": "^8.48.0",
"prettier": "^3.0.3",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^5.0.0"
"eslint-plugin-prettier": "^5.0.0",
"prettier": "^3.0.3"
},
"devDependencies": {
"prettier-plugin-organize-imports": "^3.2.3"
}
}
38 changes: 38 additions & 0 deletions packages/eslint-config/prettier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
'prettier/prettier': [
'error',
{
tabWidth: 2,
semi: true,
singleQuote: true,
trailingComma: 'none',
printWidth: 120,
htmlWhitespaceSensitivity: 'ignore',
jsxBracketSameLine: true,
plugins: ['prettier-plugin-organize-imports'],
overrides: [
{
files: '*.html',
options: {
parser: 'html',
htmlWhitespaceSensitivity: 'ignore',
singleQuote: false
}
},
{
files: '*.component.html',
options: {
parser: 'angular',
htmlWhitespaceSensitivity: 'ignore',
}
},
{
files: ['*.scss'],
options: {
singleQuote: false
}
}
]
}
]
}
Loading

0 comments on commit ee8ac41

Please sign in to comment.