Skip to content

Commit 64d2bb1

Browse files
committed
setup project
1 parent 52b4699 commit 64d2bb1

File tree

6 files changed

+4300
-0
lines changed

6 files changed

+4300
-0
lines changed

Diff for: .babelrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"presets": [
3+
["env", {
4+
"targets": {
5+
"node": "6.14.2"
6+
}
7+
}]
8+
]
9+
}

Diff for: .eslintrc.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
extends: 'standard',
3+
plugins: [
4+
'standard',
5+
'promise'
6+
],
7+
// add your custom rules here
8+
rules: {
9+
// allow paren-less arrow functions
10+
'arrow-parens': 0,
11+
'no-useless-constructor': 0,
12+
'no-extra-bind': 1,
13+
'handle-callback-err': 1,
14+
'prefer-promise-reject-errors': 1,
15+
'space-before-function-paren': 0
16+
}
17+
}

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@ typings/
5959

6060
# next.js build output
6161
.next
62+
63+
# serverless
64+
.serverless
65+
dist

Diff for: package.json

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "spider-less",
3+
"version": "1.0.0",
4+
"description": "Spider on serverless",
5+
"main": "src/index.js",
6+
"repository": "https://github.com/slashbit/spider-less",
7+
"author": "slashbit",
8+
"license": "MIT",
9+
"engines": {
10+
"node": ">= 6.14.2",
11+
"npm": ">= 3.10.10"
12+
},
13+
"engineStrict": true,
14+
"scripts": {
15+
"lint": "./node_modules/eslint/bin/eslint.js src/**/*.js",
16+
"sls": "./node_modules/serverless/bin/serverless",
17+
"start": "yarn sls offline start --port 8090",
18+
"deploy": "yarn lint && yarn sls deploy",
19+
"log": "yarn sls logs -t --function",
20+
"invoke": "yarn sls invoke --function",
21+
"invoke:local": "yarn sls invoke local --env IS_LOCAL=true --function"
22+
},
23+
"pre-commit": [
24+
"lint"
25+
],
26+
"test": "echo \"test\"",
27+
"dependencies": {
28+
"body-parser": "^1.18.2",
29+
"bufferhelper": "^0.2.1",
30+
"cheerio": "^1.0.0-rc.2",
31+
"dayjs": "^1.7.7",
32+
"express": "^4.16.2",
33+
"express-validation": "^1.0.2",
34+
"iconv-lite": "^0.4.19",
35+
"joi": "12",
36+
"morgan": "^1.9.0",
37+
"request": "^2.83.0",
38+
"serverless-http": "^1.5.2",
39+
"signale": "^1.3.0",
40+
"uuid": "^3.1.0"
41+
},
42+
"devDependencies": {
43+
"aws-sdk": "^2.168.0",
44+
"eslint": "^4.14.0",
45+
"eslint-config-standard": "^11.0.0-beta.0",
46+
"eslint-plugin-import": "^2.8.0",
47+
"eslint-plugin-node": "^5.2.1",
48+
"eslint-plugin-promise": "^3.6.0",
49+
"eslint-plugin-standard": "^3.0.1",
50+
"pre-commit": "^1.2.2",
51+
"serverless": "^1.25.0",
52+
"serverless-offline": "^3.16.0"
53+
},
54+
"signale": {
55+
"displayTimestamp": true
56+
}
57+
}

Diff for: serverless.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
service: spider-less
2+
3+
provider:
4+
name: aws
5+
runtime: nodejs6.10
6+
region: ${self:custom.defaultRegion}
7+
stage: ${env:NODE_ENV, self:custom.defaultNodeEnv}
8+
environment:
9+
NODE_ENV: ${env:NODE_ENV, self:custom.defaultNodeEnv}
10+
REGION: ${self:provider.region}
11+
TABLE_SUBSCRIPTIONS: ${self:service}-subscriptions-${self:provider.stage}
12+
iamRoleStatements:
13+
- Effect: Allow
14+
Action:
15+
- dynamodb:Query
16+
- dynamodb:Scan
17+
- dynamodb:GetItem
18+
- dynamodb:PutItem
19+
- dynamodb:UpdateItem
20+
- dynamodb:DeleteItem
21+
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/*"
22+
23+
functions:
24+
http:
25+
handler: src/index.api
26+
timeout: 30
27+
events:
28+
- http:
29+
path: /{proxy+}
30+
method: any
31+
cors: true
32+
cron:
33+
handler: src/index.cron
34+
timeout: 60
35+
events:
36+
- schedule:
37+
rate: rate(60 minutes)
38+
scrape:
39+
handler: src/index.scrape
40+
timeout: 60
41+
memorySize: 1536
42+
43+
resources:
44+
Resources:
45+
SubscriptionsTable:
46+
Type: AWS::DynamoDB::Table
47+
DeletionPolicy: Retain # Keeps around the DynamoDB resource when we redeploy/destroy
48+
Properties:
49+
TableName: ${self:provider.environment.TABLE_SUBSCRIPTIONS}
50+
AttributeDefinitions:
51+
- AttributeName: id
52+
AttributeType: S
53+
KeySchema:
54+
- AttributeName: id
55+
KeyType: HASH
56+
ProvisionedThroughput:
57+
ReadCapacityUnits: 1
58+
WriteCapacityUnits: 1
59+
60+
plugins:
61+
- serverless-offline
62+
63+
custom:
64+
defaultRegion: us-east-1
65+
defaultNodeEnv: dev
66+
serverless-offline:
67+
dontPrintOutput: true

0 commit comments

Comments
 (0)