Skip to content

Commit

Permalink
update eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
aboutmydreams committed May 28, 2022
1 parent 9e293f3 commit 8dc7977
Show file tree
Hide file tree
Showing 8 changed files with 5,437 additions and 147 deletions.
7 changes: 4 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ module.exports = {
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"google",
"plugin:@typescript-eslint/recommended",
// "plugin:@typescript-eslint/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["tsconfig.json", "tsconfig.dev.json"],
project: ["jsconfig.json", "tsconfig.dev.json"],
sourceType: "module",
},
ignorePatterns: [
"/lib/**/*", // Ignore built files.
"/coverage/**/*",
"jest.config.ts",
".eslintrc.js",
"jsconfig.json",
],
plugins: ["@typescript-eslint", "import"],
rules: {
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: deploy

on:
pull_requests:
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./
steps:
- uses: actions/checkout@v2
- run: mkdir -p /home/runner/.npm
continue-on-error: true

- name: Use Node.js 12
uses: actions/setup-node@v2
with:
node-version: 12
cache: 'npm'
cache-dependency-path: ./package-lock.json


- name: npm install
run: npm install
- name: npm install serverless
run: npm i -g serverless serverless-tencent
- name: run eslint fix
run: eslint "./**.js" --fix

108 changes: 55 additions & 53 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,81 +1,83 @@
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const fs = require('fs');
const feishu = require('./feishuWebhook');
const app = express();
const express = require("express")
const bodyParser = require("body-parser")
const path = require("path")
const fs = require("fs")
const feishu = require("./feishuWebhook")
const app = express()
// https://stackabuse.com/get-http-post-body-in-express-js/
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.urlencoded({ extended: true }))

app.get(`/`, (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "index.html"))
})

app.get(`/release`, (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
app.get("/release", (req, res) => {
res.sendFile(path.join(__dirname, "index.html"))
})

app.get(`/logo`, (req, res) => {
const logo = path.join(__dirname, 'logo.png');
app.get("/logo", (req, res) => {
const logo = path.join(__dirname, "logo.png")
const content = fs.readFileSync(logo, {
encoding: 'base64',
});
res.set('Content-Type', 'image/png');
res.send(Buffer.from(content, 'base64'));
res.status(200).end();
});
encoding: "base64",
})
res.set("Content-Type", "image/png")
res.send(Buffer.from(content, "base64"))
res.status(200).end()
})

app.get('/user', (req, res) => {
app.get("/user", (req, res) => {
res.send([
{
title: 'serverless framework',
link: 'https://serverless.com',
title: "serverless framework",
link: "https://serverless.com",
},
]);
});
])
})

app.get('/user/:id', (req, res) => {
const id = req.params.id;
app.get("/user/:id", (req, res) => {
const id = req.params.id
res.send({
id: id,
title: 'serverless framework',
link: 'https://serverless.com',
});
});
title: "serverless framework",
link: "https://serverless.com",
})
})

app.get('/404', (req, res) => {
res.status(404).send('Not found');
});
app.get("/404", (req, res) => {
res.status(404).send("Not found")
})

app.get('/500', (req, res) => {
res.status(500).send('Server Error');
});
app.get("/500", (req, res) => {
res.status(500).send("Server Error")
})

// Error handler
app.use(function (err, req, res, next) {
console.error(err);
res.status(500).send('Internal Serverless Error');
});
console.error(err)
console.log(req)
console.log(next)
res.status(500).send("Internal Serverless Error")
})

// Web 类型云函数,只能监听 9000 端口
app.listen(9000, () => {
console.log(`Server start on http://localhost:9000`);
});
console.log("Server start on http://localhost:9000")
})


app.post('/feishu', (req, res) => {
app.post("/feishu", (req, res) => {
feishu.forwardMessageFeishu(req, res)
});
})

app.post(`/release/feishu`, (req, res) => {
app.post("/release/feishu", (req, res) => {
feishu.forwardMessageFeishu(req, res)
});
})


app.get('/feishu', (req, res) => {
res.status(200).send({ tip: "You should use the post request, see doc: https://githubbot.ahaclub.net" });
});
app.get("/feishu", (req, res) => {
res.status(200).send({ tip: "You should use the post request, see doc: https://githubbot.ahaclub.net" })
})

app.get('/release/feishu', (req, res) => {
res.status(200).send({ tip: "You should use the post request, see doc: https://githubbot.ahaclub.net" });
});
app.get("/release/feishu", (req, res) => {
res.status(200).send({ tip: "You should use the post request, see doc: https://githubbot.ahaclub.net" })
})
6 changes: 3 additions & 3 deletions feishuWebhook.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const rp = require('request');
const rp = require("request")


// forwardMessageFeishu()
Expand Down Expand Up @@ -128,5 +128,5 @@ function getMessageBody(eventName, eventBody, eventUrl, senderName) {
],
},
}
return body;
};
return body
}
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ <h1>
at your service
<div>
<h4>How to use?</h4>
<p>1. open a feishu group and add a bot</p>
<p>2. copy the bot webhook url</p>
<p>1. Add a bot in a feishu group</p>
<p>2. Copy the bot webhook url</p>
<p>
3. join the url:
3. Concatenate as url:
https://githubbot.ahaclub.net/feishu?url={your-feishu-bot-webhook-url}
</p>
<p>4. open a github repo setting page and add it to webhook</p>
<p>4. Open a github repo setting page and add the url to webhook</p>
<h4>About Aha?</h4>
<p>
Visit our website
Expand Down
Loading

0 comments on commit 8dc7977

Please sign in to comment.