Skip to content

Commit

Permalink
Merge branch 'master' into fix/join-workspace-using-invitation-link
Browse files Browse the repository at this point in the history
  • Loading branch information
robonetphy authored Feb 1, 2022
2 parents 598a1ce + fddfcdc commit 09fab7c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"mime-types": "^2.1.25",
"mongodb": "^3.4.0",
"mustache": "^3.0.1",
"nodemailer": "^6.4.2",
"nodemailer": "^6.6.1",
"passport": "^0.4.1",
"passport-github": "^1.1.0",
"passport-jwt": "^4.0.0",
Expand Down
17 changes: 12 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ class HawkAPI {
* Requires PORT and MONGO_URL env vars to be set.
*/
constructor() {
/**
* Allow CORS requests.
*/
this.app.use(async (req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', `${process.env.GARAGE_URL}`);
res.setHeader('Access-Control-Allow-Credentials', 'true');
res.setHeader('Access-Control-Allow-Methods', 'GET,HEAD,OPTIONS,POST,PUT');
res.setHeader('Access-Control-Allow-Headers', 'Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers');
next();
});
this.app.use(express.json());
this.app.use(bodyParser.urlencoded({ extended: false }));
this.app.use('/uploads', express.static(`./${process.env.UPLOADS_DIR || 'uploads'}`));
Expand All @@ -84,7 +94,6 @@ class HawkAPI {
*/
this.app.use(async (req, res, next) => {
req.context = await HawkAPI.createContext({ req } as ExpressContext);

next();
});

Expand Down Expand Up @@ -261,13 +270,11 @@ class HawkAPI {
return new Promise((resolve) => {
this.httpServer.listen({ port: this.serverPort }, () => {
console.log(
`🚀 Server ready at http://localhost:${this.serverPort}${
this.server.graphqlPath
`🚀 Server ready at http://localhost:${this.serverPort}${this.server.graphqlPath
}`
);
console.log(
`🚀 Subscriptions ready at ws://localhost:${this.serverPort}${
this.server.subscriptionsPath
`🚀 Subscriptions ready at ws://localhost:${this.serverPort}${this.server.subscriptionsPath
}`
);
resolve();
Expand Down
4 changes: 3 additions & 1 deletion src/models/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,15 @@ export default class WorkspaceModel extends AbstractModel<WorkspaceDBScheme> imp
* @param planId - id of plan to be enabled
*/
public async changePlan(planId: ObjectId | string): Promise<number> {
this.tariffPlanId = new ObjectId(planId);

return (await this.collection.updateOne(
{
_id: new ObjectId(this._id),
},
{
$set: {
tariffPlanId: new ObjectId(planId),
tariffPlanId: this.tariffPlanId,
billingPeriodEventsCount: 0,
isBlocked: false,
lastChargeDate: new Date(),
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3438,9 +3438,9 @@ fn-args@5.0.0:
integrity sha512-CtbfI3oFFc3nbdIoHycrfbrxiGgxXBXXuyOl49h47JawM1mYrqpiRqnH5CB2mBatdXvHHOUO6a+RiAuuvKt0lw==

follow-redirects@^1.10.0, follow-redirects@^1.14.0:
version "1.14.4"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379"
integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==
version "1.14.7"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685"
integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==

for-in@^1.0.2:
version "1.0.2"
Expand Down Expand Up @@ -5668,10 +5668,10 @@ node-pre-gyp@^0.14.0:
semver "^5.3.0"
tar "^4.4.2"

nodemailer@^6.4.2:
version "6.4.18"
resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.4.18.tgz#2788c85792844fc17befda019031609017f4b9a1"
integrity sha512-ht9cXxQ+lTC+t00vkSIpKHIyM4aXIsQ1tcbQCn5IOnxYHi81W2XOaU66EQBFFpbtzLEBTC94gmkbD4mGZQzVpA==
nodemailer@^6.6.1:
version "6.6.1"
resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.6.1.tgz#2a05fbf205b897d71bf43884167b5d4d3bd01b99"
integrity sha512-1xzFN3gqv+/qJ6YRyxBxfTYstLNt0FCtZaFRvf4Sg9wxNGWbwFmGXVpfSi6ThGK6aRxAo+KjHtYSW8NvCsNSAg==

nodemon@^2.0.2:
version "2.0.7"
Expand Down

0 comments on commit 09fab7c

Please sign in to comment.