Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Esm migration #20

Merged
merged 4 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
{
"extends": ["standard", "plugin:security/recommended"],
"extends": ["standard", "plugin:security/recommended", "plugin:unicorn/recommended"],
"plugins": ["unicorn"],
"parserOptions": {
"sourceType": "module"
},
"globals": {
"describe": "readonly",
"test": "readonly",
"expect": "readonly"
},
"rules": {
"unicorn/prefer-module":"error",
"unicorn/filename-case": [
"error",
{
"case": "camelCase"
}
],
"unicorn/prevent-abbreviations": [
"error",
{
"allowList": {
"dynamoDb": true
}
}
]
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.nyc_output
.serverless
.tap
35 changes: 12 additions & 23 deletions handler.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
'use strict'

const parser = require('body-parser-for-serverless')

const handlerFactory = require('./src/handlers/handlerFactory')

const slackTextResponse = require('./src/utils/slackTextResponse')
const coinRepository = require('./src/lib/coinRepository')
const coinTicketParser = require('./src/lib/coinTicketParser')
import parser from 'body-parser-for-serverless'
import { handlerFactory } from './src/handlers/handlerFactory.js'
import { slackTextResponsePrivate } from './src/utils/slackTextResponse.js'
import { coinRepository } from './src/lib/coinRepository.js'
import { coinTicketParser } from './src/lib/coinTicketParser.js'

const health = async (event) => {
return {
Expand All @@ -18,22 +14,15 @@ const health = async (event) => {
}
}

const getResult = async body => {
const {
text
} = body

const userName = body.user_name
const responseUrl = body.response_url

const getResult = async ({ text, user_name: userName, response_url: responseUrl }) => {
const handler = handlerFactory(userName, text)

if (handler) {
const result = await handler.handle(userName, text, responseUrl)
return result
}

return slackTextResponse.private(`
return slackTextResponsePrivate(`
Sorry I did not understand your command, try \`/coin help\` to get some help.
_Original Message:_ \`/coin ${text}\`
`)
Expand All @@ -58,10 +47,10 @@ const send = async (event) => {
'Content-Type': 'application/json'
}
}
} catch (err) {
} catch (error) {
return {
statusCode: 500,
body: err.message
body: error.message
}
}
}
Expand Down Expand Up @@ -92,15 +81,15 @@ const csv = async (event) => {
'Content-Type': 'text/csv'
}
}
} catch (err) {
} catch (error) {
return {
statusCode: 500,
body: err.message
body: error.message
}
}
}

module.exports.v1 = {
export const v1 = {
send,
health,
csv
Expand Down
Loading