Skip to content

Commit a441204

Browse files
authored
Merge pull request #26 from aymenn/eslint-config
Implement standard eslint styleguide and lint project
2 parents 2b0c59c + 9d9841f commit a441204

38 files changed

+4309
-4420
lines changed

.eslintrc.js

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

.eslintrc.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"standard"
9+
],
10+
"parser": "@typescript-eslint/parser",
11+
"parserOptions": {
12+
"ecmaVersion": 12,
13+
"sourceType": "module"
14+
},
15+
"plugins": [
16+
"@typescript-eslint"
17+
],
18+
"rules": {
19+
},
20+
"overrides": [
21+
{
22+
"files": [
23+
"**/*.test.js",
24+
"**/*.test.ts"
25+
],
26+
"env": {
27+
"jest": true
28+
}
29+
}
30+
]
31+
}

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ module.exports = {
33
preset: 'ts-jest',
44
testEnvironment: 'node',
55
setupFiles: ['<rootDir>/tests/.jest/setEnvVars.js']
6-
};
6+
}

package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
"@types/morgan": "^1.9.3",
2121
"@types/node": "^18.0.1",
2222
"@types/supertest": "^2.0.12",
23+
"@typescript-eslint/eslint-plugin": "^5.32.0",
24+
"@typescript-eslint/parser": "^5.32.0",
25+
"eslint": "^8.21.0",
26+
"eslint-config-standard": "^17.0.0",
27+
"eslint-plugin-import": "^2.26.0",
28+
"eslint-plugin-n": "^15.2.4",
29+
"eslint-plugin-promise": "^6.0.0",
2330
"jest": "^28.1.3",
2431
"node-fetch": "2",
2532
"nodemon": "^2.0.19",
@@ -28,11 +35,14 @@
2835
"ts-node": "^10.8.2",
2936
"typescript": "^4.7.4"
3037
},
31-
"name": "masked-communications",
38+
"name": "masked-comms-app",
3239
"scripts": {
3340
"dev": "nodemon -r dotenv/config index.ts",
3441
"loadtest": "node ./tests/loadtest.js",
3542
"test": "jest"
3643
},
37-
"version": "1.0.0"
44+
"version": "1.0.0",
45+
"main": "index.js",
46+
"repository": "[email protected]:aymenn/masked-comms-app.git",
47+
"license": "MIT"
3848
}

src/@types/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { Request } from "express";
2-
import { ConversationListInstanceCreateOptions } from "twilio/lib/rest/conversations/v1/conversation";
1+
import type { Request } from 'express'
2+
import { ConversationListInstanceCreateOptions } from 'twilio/lib/rest/conversations/v1/conversation'
33

44
export interface SessionPostBody extends ConversationListInstanceCreateOptions {
55
addresses: Array<string>;
66
}
7-
7+
88
export interface ConversationsPostEventBody {
99
AccountSid: string;
1010
Attributes: string;
@@ -41,4 +41,4 @@ export interface JoinConferenceParams extends Request {
4141
export interface ParticipantToDial {
4242
address: string,
4343
proxyAddress: string
44-
}
44+
}

src/config/webhookValidationConfig.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function shouldValidate () {
33
}
44

55
export const webhookConfig = {
6-
protocol: 'https',
7-
host: process.env.DOMAIN,
8-
validate: shouldValidate()
9-
}
6+
protocol: 'https',
7+
host: process.env.DOMAIN,
8+
validate: shouldValidate()
9+
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { Request, Response } from "express";
2-
import { ConversationsPostEventBody } from "../@types/types";
3-
import { deleteConversation } from "../utils/deleteConversation.util";
1+
import type { Request, Response } from 'express'
2+
import { ConversationsPostEventBody } from '../@types/types'
3+
import { deleteConversation } from '../utils/deleteConversation.util'
44

55
export const post = async (
66
req: Request<{}, {}, ConversationsPostEventBody>,
@@ -10,15 +10,15 @@ export const post = async (
1010
EventType: eventType,
1111
State: state,
1212
ConversationSid: conversationSid
13-
} = req.body;
14-
15-
if (eventType === "onConversationUpdated" && state === "closed") {
13+
} = req.body
14+
15+
if (eventType === 'onConversationUpdated' && state === 'closed') {
1616
try {
1717
await deleteConversation(conversationSid)
18-
} catch(err) {
18+
} catch (err) {
1919
return res.status(500).send(`${conversationSid} failed to delete: ${err}`)
2020
}
2121
return res.status(200).send(`${conversationSid} deleted`)
2222
}
2323
return res.status(200).send('not processed')
24-
};
24+
}

src/controllers/inboundCall.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Request, Response } from "express";
2-
import { generateTwiml } from "../services/inboundCall.service";
1+
import type { Request, Response } from 'express'
2+
import { generateTwiml } from '../services/inboundCall.service'
33

44
export const post = async (
55
req: Request,
@@ -8,9 +8,8 @@ export const post = async (
88
const from = req.body.From
99
const to = req.body.Called
1010

11-
const twiml = await generateTwiml(from, to);
11+
const twiml = await generateTwiml(from, to)
1212

1313
res.set('Content-Type', 'text/xml')
1414
res.send(twiml.toString())
15-
16-
};
15+
}

src/controllers/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * as conversationsPostEvent from "./conversationsPostEvent";
2-
export * as inboundCall from "./inboundCall";
3-
export * as session from "./session";
4-
export * as joinConference from "./joinConference"
1+
export * as conversationsPostEvent from './conversationsPostEvent'
2+
export * as inboundCall from './inboundCall'
3+
export * as session from './session'
4+
export * as joinConference from './joinConference'

src/controllers/joinConference.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { Response } from "express";
2-
import { JoinConferenceParams } from "../@types/types";
3-
import VoiceResponse from "twilio/lib/twiml/VoiceResponse";
1+
import type { Response } from 'express'
2+
import { JoinConferenceParams } from '../@types/types'
3+
import VoiceResponse from 'twilio/lib/twiml/VoiceResponse'
44

55
function joinConferenceTwiml (conferenceName: string) : VoiceResponse {
66
const response = new VoiceResponse()
7-
const dial = response.dial();
8-
dial.conference(`${decodeURIComponent(conferenceName)}`);
7+
const dial = response.dial()
8+
dial.conference(`${decodeURIComponent(conferenceName)}`)
99

1010
return response
1111
}
@@ -15,8 +15,8 @@ export const get = async (
1515
res: Response
1616
) => {
1717
const conferenceName = req.query.conferenceName
18-
const twiml = await joinConferenceTwiml(conferenceName as string);
18+
const twiml = await joinConferenceTwiml(conferenceName as string)
1919

2020
res.set('Content-Type', 'text/xml')
2121
res.send(twiml.toString())
22-
};
22+
}

0 commit comments

Comments
 (0)