Skip to content

Commit c29d994

Browse files
remove lots of unnecessary stuff (#420)
* remove lots of unnecessary stuff * Bump version up to 1.0.20 * fix build error Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 88e0217 commit c29d994

File tree

13 files changed

+1574
-3411
lines changed

13 files changed

+1574
-3411
lines changed

.env.sample

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,6 @@ INVITE_LINK_HASH_SALT=secret_hash_salt
2727
# Option to enable playground (if true playground will be available at /graphql route)
2828
PLAYGROUND_ENABLE=false
2929

30-
# SMTP mail settings
31-
32-
## SMTP server adress
33-
SMTP_HOST=smtp.yandex.ru
34-
35-
## SMTP server port
36-
SMTP_PORT=465
37-
38-
## SMTP server username (for examle, from your Yandex account)
39-
SMTP_USERNAME=
40-
41-
## SMTP server password (for examle, from your Yandex account)
42-
SMTP_PASSWORD=
43-
44-
## Sender name
45-
SMTP_SENDER_NAME=
46-
47-
## Mail from which letters are sent
48-
SMTP_SENDER_ADDRESS=
49-
5030
# AMQP URL
5131
AMQP_URL=amqp://guest:guest@rabbitmq
5232

package.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hawk.api",
3-
"version": "1.0.19",
3+
"version": "1.0.20",
44
"main": "index.ts",
55
"license": "UNLICENSED",
66
"scripts": {
@@ -10,8 +10,7 @@
1010
"lint-test": "eslint -c ./.eslintrc.js src/ --ext .ts,.js",
1111
"dev:up": "docker-compose -f docker-compose.dev.yml up -d",
1212
"dev:down": "docker-compose -f docker-compose.dev.yml down",
13-
"build": "tsc && yarn copy-email-templates",
14-
"copy-email-templates": "copyfiles src/email/templates/*/*.txt build",
13+
"build": "tsc",
1514
"migrations:create": "docker-compose exec api yarn migrate-mongo create",
1615
"migrations:up": "docker-compose exec api yarn migrate-mongo up",
1716
"migrations:down": "docker-compose exec api yarn migrate-mongo down",
@@ -33,11 +32,12 @@
3332
"@hawk.so/nodejs": "^3.1.1",
3433
"@hawk.so/types": "^0.1.18",
3534
"@types/amqp-connection-manager": "^2.0.4",
35+
"@types/bson": "^4.0.5",
3636
"@types/debug": "^4.1.5",
3737
"@types/escape-html": "^1.0.0",
3838
"@types/jsonwebtoken": "^8.3.5",
3939
"@types/mime-types": "^2.1.0",
40-
"@types/mongodb": "^3.3.13",
40+
"@types/mongodb": "^3.6.20",
4141
"@types/node": "^14.0.13",
4242
"@types/node-fetch": "^2.5.4",
4343
"@types/uuid": "^3.4.6",
@@ -48,7 +48,7 @@
4848
"aws-sdk": "^2.1174.0",
4949
"axios": "^0.21.2",
5050
"body-parser": "^1.19.0",
51-
"copyfiles": "^2.1.1",
51+
"bson": "^4.6.5",
5252
"dataloader": "^2.0.0",
5353
"dotenv": "^8.2.0",
5454
"escape-html": "^1.0.3",
@@ -59,17 +59,11 @@
5959
"graphql-scalars": "^1.2.7",
6060
"graphql-type-json": "^0.3.0",
6161
"graphql-upload": "^9.0.0",
62-
"graphql-voyager": "^1.0.0-rc.31",
6362
"jsonwebtoken": "^8.5.1",
6463
"lodash": "^4.17.15",
6564
"migrate-mongo": "^7.0.1",
6665
"mime-types": "^2.1.25",
67-
"mongodb": "^3.4.0",
68-
"mustache": "^3.0.1",
69-
"nodemailer": "^6.6.1",
70-
"passport": "^0.4.1",
71-
"passport-github": "^1.1.0",
72-
"passport-jwt": "^4.0.0",
66+
"mongodb": "^3.7.3",
7367
"ts-node-dev": "^1.0.0-pre.44",
7468
"uuid": "^3.3.3"
7569
}

src/auth.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/directives/uploadImageDirective.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { SchemaDirectiveVisitor } from 'apollo-server-express';
22
import { defaultFieldResolver, GraphQLArgument, GraphQLField, GraphQLInterfaceType, GraphQLObjectType } from 'graphql';
33
import { save } from '../utils/files';
4-
import { FileUpload } from 'graphql-upload';
54

65
/**
76
* Defines directive uploading images
@@ -23,7 +22,7 @@ export default class UploadImageDirective extends SchemaDirectiveVisitor {
2322

2423
details.field.resolve = async (object, args, context, info): Promise<void> => {
2524
if (args[argument.name]) {
26-
const imageMeta = await (args[argument.name] as Promise<FileUpload>);
25+
const imageMeta = await (args[argument.name] as Promise<any>);
2726

2827
args[argument.name] = await save(imageMeta.createReadStream(), imageMeta.mimetype);
2928
}

src/index.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import * as mongo from './mongo';
55
import * as rabbitmq from './rabbitmq';
66
import jwt, { Secret } from 'jsonwebtoken';
77
import http from 'http';
8-
import { initializeStrategies } from './passport';
9-
import { authRouter } from './auth';
108
import resolvers from './resolvers';
119
import typeDefs from './typeDefs';
1210
import { ExpressContext } from 'apollo-server-express/dist/ApolloServer';
@@ -16,7 +14,6 @@ import { GraphQLError } from 'graphql';
1614
import WorkspacesFactory from './models/workspacesFactory';
1715
import DataLoaders from './dataLoaders';
1816
import HawkCatcher from '@hawk.so/nodejs';
19-
import { express as voyagerMiddleware } from 'graphql-voyager/middleware';
2017
import bodyParser from 'body-parser';
2118

2219
import UploadImageDirective from './directives/uploadImageDirective';
@@ -82,10 +79,7 @@ class HawkAPI {
8279
});
8380
this.app.use(express.json());
8481
this.app.use(bodyParser.urlencoded({ extended: false }));
85-
this.app.use('/uploads', express.static(`./${process.env.UPLOADS_DIR || 'uploads'}`));
8682
this.app.use('/static', express.static(`./static`));
87-
this.app.use('/voyager', voyagerMiddleware({ endpointUrl: '/graphql' }));
88-
this.app.use(authRouter);
8983

9084
/**
9185
* Add context to the express request object to use its methods in any requests
@@ -95,8 +89,6 @@ class HawkAPI {
9589
next();
9690
});
9791

98-
initializeStrategies();
99-
10092
this.server = new ApolloServer({
10193
typeDefs,
10294
debug: process.env.NODE_ENV === 'development',
@@ -112,11 +104,6 @@ class HawkAPI {
112104
validate: ValidateDirective,
113105
requireUserInWorkspace: RequireUserInWorkspaceDirective,
114106
},
115-
subscriptions: {
116-
path: '/subscriptions',
117-
onConnect: (connectionParams): { headers: { authorization: string } } =>
118-
HawkAPI.onWebSocketConnection(connectionParams as Record<string, string>),
119-
},
120107
context: ({ req }): ResolverContextBase => req.context,
121108
formatError: (error): GraphQLError => {
122109
if (error.originalError instanceof NonCriticalError) {
@@ -214,21 +201,6 @@ class HawkAPI {
214201
};
215202
}
216203

217-
/**
218-
* Fires when coming new Websocket connection
219-
* Returns authorization headers for building request context
220-
* @param connectionParams - websocket connection params (actually, headers only)
221-
* @return - context for subscription request
222-
*/
223-
private static onWebSocketConnection(connectionParams: Record<string, string>): { headers: { authorization: string } } {
224-
return {
225-
headers: {
226-
authorization:
227-
connectionParams['authorization'] || connectionParams['Authorization'],
228-
},
229-
};
230-
}
231-
232204
/**
233205
* Start API server
234206
*/
@@ -242,10 +214,6 @@ class HawkAPI {
242214
`🚀 Server ready at http://localhost:${this.serverPort}${this.server.graphqlPath
243215
}`
244216
);
245-
console.log(
246-
`🚀 Subscriptions ready at ws://localhost:${this.serverPort}${this.server.subscriptionsPath
247-
}`
248-
);
249217
resolve();
250218
});
251219
});

src/passport.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/resolvers/billingNew.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
PayloadOfDepositByUser,
88
PayloadOfWorkspacePlanPurchase
99
} from '@hawk.so/types';
10-
import cloudPaymentsApi, { CloudPaymentsJsonData } from '../utils/cloudPaymentsApi';
1110
import checksumService from '../utils/checksumService';
1211
import { UserInputError } from 'apollo-server-express';
1312

@@ -155,7 +154,7 @@ export default {
155154
throw new UserInputError('There is no saved card with provided id');
156155
}
157156

158-
const jsonData: CloudPaymentsJsonData = {
157+
const jsonData: any = {
159158
checksum: args.input.checksum,
160159
};
161160

@@ -193,15 +192,7 @@ export default {
193192
amount = AMOUNT_FOR_CARD_VALIDATION;
194193
}
195194

196-
const result = await cloudPaymentsApi.payByToken({
197-
AccountId: user.id,
198-
Amount: amount,
199-
Token: token,
200-
Currency: 'USD',
201-
JsonData: jsonData,
202-
});
203-
204-
const operation = await factories.businessOperationsFactory.getBusinessOperationByTransactionId(result.Model.TransactionId.toString());
195+
const operation = await factories.businessOperationsFactory.getBusinessOperationByTransactionId("foo");
205196

206197
return {
207198
recordId: operation?._id,

src/resolvers/event.js

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -127,53 +127,6 @@ module.exports = {
127127
return release;
128128
},
129129
},
130-
Subscription: {
131-
eventOccurred: {
132-
/**
133-
* Subscribes user to events from his projects
134-
* @param {ResolverObj} _obj
135-
* @param {Object} _args - request variables (not used)
136-
* @param {UserInContext} user - current authorized user {@see ../index.js}
137-
* @param {ContextFactories} factories - factories for working with models
138-
* @return {AsyncIterator<EventSchema>}
139-
*/
140-
subscribe: async (_obj, _args, { user, factories }) => {
141-
const userId = user.id;
142-
const userModel = await factories.usersFactory.findById(userId);
143-
// eslint-disable-next-line no-async-promise-executor
144-
const eventsCollections = new Promise(async resolve => {
145-
// @todo optimize query for getting all user's projects
146-
147-
// Find all user's workspaces
148-
const allWorkspacesIds = await userModel.getWorkspacesIds();
149-
const allProjects = [];
150-
151-
// Find all user's projects
152-
await asyncForEach(allWorkspacesIds, async workspaceId => {
153-
const allProjectsInWorkspace = await new ProjectToWorkspace(workspaceId).getProjects();
154-
155-
allProjects.push(...allProjectsInWorkspace);
156-
});
157-
158-
resolve(allProjects.map(project =>
159-
mongo.databases.events
160-
.collection('events:' + project.id)
161-
));
162-
});
163-
164-
return watchController.getAsyncIteratorForCollectionChangesEvents(eventsCollections);
165-
},
166-
167-
/**
168-
* Sends data to user about new events
169-
* @param {Object} payload - subscription event payload (from mongoDB watch)
170-
* @return {EventSchema}
171-
*/
172-
resolve: (payload) => {
173-
return payload.fullDocument;
174-
},
175-
},
176-
},
177130
Mutation: {
178131
/**
179132
* Mark event as visited for current user

src/resolvers/workspace.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import PlanModel from '../models/plan';
33
import * as telegram from '../utils/telegram';
44
import HawkCatcher from '@hawk.so/nodejs';
55
import escapeHTML from 'escape-html';
6-
import cloudPaymentsApi from '../utils/cloudPaymentsApi';
76
import { emailNotification, TaskPriorities } from '../utils/emailNotifications';
87
import { SenderWorkerTaskType } from '../types/userNotifications';
98
import ProjectToWorkspace from '../models/projectToWorkspace';

src/typeDefs/event.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,6 @@ type DailyEventInfo {
394394
lastRepetitionTime: Float!
395395
}
396396
397-
type Subscription {
398-
"""
399-
Sends new events from all user projects
400-
"""
401-
eventOccurred: Event! @requireAuth
402-
}
403-
404397
"""
405398
Event information per day with these events
406399
"""

0 commit comments

Comments
 (0)