Spaces:
Sleeping
Sleeping
Rick Knowles
commited on
Commit
·
94d5fc0
1
Parent(s):
ace9d6e
added skeleton container
Browse files- .eslintignore +1 -0
- .eslintrc.json +36 -0
- .gitignore +2 -0
- .npmrc +1 -0
- .prettierignore +1 -0
- .prettierrc +6 -0
- Dockerfile +36 -0
- __tests__/index.ts +3 -0
- config.json +8 -0
- docker-compose.yml +12 -0
- lib/config.ts +9 -0
- lib/index.ts +13 -0
- lib/logging.ts +12 -0
- lib/route/index.ts +7 -0
- lib/server.ts +16 -0
- package-lock.json +0 -0
- package.json +41 -0
- static/index.html +9 -0
- tsconfig.json +10 -0
.eslintignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
/es5/
|
.eslintrc.json
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"extends": [
|
3 |
+
"airbnb-base",
|
4 |
+
"prettier",
|
5 |
+
"plugin:@typescript-eslint/recommended"
|
6 |
+
],
|
7 |
+
"env": {
|
8 |
+
"jest": true,
|
9 |
+
"node": true
|
10 |
+
},
|
11 |
+
"rules": {
|
12 |
+
"prettier/prettier": ["error"],
|
13 |
+
"import/extensions": "off",
|
14 |
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
15 |
+
"@typescript-eslint/no-explicit-any": "off",
|
16 |
+
"import/prefer-default-export": "off",
|
17 |
+
"import/no-extraneous-dependencies": [
|
18 |
+
"error",
|
19 |
+
{
|
20 |
+
"devDependencies": ["**/*.test.ts", "**/*.spec.ts"]
|
21 |
+
}
|
22 |
+
],
|
23 |
+
"camelcase": "off"
|
24 |
+
},
|
25 |
+
"plugins": ["prettier", "@typescript-eslint", "import"],
|
26 |
+
"settings": {
|
27 |
+
"import/parsers": {
|
28 |
+
"@typescript-eslint/parser": [".ts"]
|
29 |
+
},
|
30 |
+
"import/resolver": {
|
31 |
+
"typescript": {
|
32 |
+
"alwaysTryTypes": true
|
33 |
+
}
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
node_modules
|
2 |
+
es5
|
.npmrc
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
#always-auth=true
|
.prettierignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
/es5/
|
.prettierrc
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"semi": true,
|
3 |
+
"singleQuote": true,
|
4 |
+
"parser": "typescript",
|
5 |
+
"printWidth": 80
|
6 |
+
}
|
Dockerfile
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM node:20 as builder
|
2 |
+
|
3 |
+
WORKDIR /app
|
4 |
+
|
5 |
+
# RUN npm set registry https://registry.npmjs.org
|
6 |
+
COPY package.json /app/package.json
|
7 |
+
COPY package-lock.json /app/package-lock.json
|
8 |
+
COPY .npmrc /app/.npmrc
|
9 |
+
RUN npm install
|
10 |
+
|
11 |
+
COPY .eslintrc.json /app/.eslintrc.json
|
12 |
+
COPY .eslintignore /app/.eslintignore
|
13 |
+
COPY .prettierrc /app/.prettierrc
|
14 |
+
COPY .prettierignore /app/.prettierignore
|
15 |
+
COPY tsconfig.json /app/tsconfig.json
|
16 |
+
COPY config.json /app/config.json
|
17 |
+
COPY lib /app/lib
|
18 |
+
COPY __tests__ /app/__tests__
|
19 |
+
COPY config.json /app/config.json
|
20 |
+
RUN npm run build
|
21 |
+
|
22 |
+
COPY static /app/static
|
23 |
+
|
24 |
+
FROM node:20
|
25 |
+
|
26 |
+
WORKDIR /app
|
27 |
+
|
28 |
+
COPY --from=builder /app/node_modules /app/node_modules
|
29 |
+
COPY --from=builder /app/es5 /app/es5
|
30 |
+
COPY --from=builder /app/static /app/static
|
31 |
+
COPY --from=builder /app/config.json /app/config.json
|
32 |
+
|
33 |
+
EXPOSE 7860
|
34 |
+
|
35 |
+
ENTRYPOINT ["node"]
|
36 |
+
CMD ["es5/server.js"]
|
__tests__/index.ts
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
describe('dummy test', () => {
|
2 |
+
it('should pass', () => {});
|
3 |
+
});
|
config.json
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"server": {
|
3 |
+
"port": 7860
|
4 |
+
},
|
5 |
+
"log": {
|
6 |
+
"level": "debug"
|
7 |
+
}
|
8 |
+
}
|
docker-compose.yml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3'
|
2 |
+
|
3 |
+
services:
|
4 |
+
app:
|
5 |
+
build:
|
6 |
+
context: .
|
7 |
+
ports:
|
8 |
+
- '7860:7860'
|
9 |
+
read_only: true
|
10 |
+
volumes:
|
11 |
+
- '../../configs/huggingface-readme:/sandbox'
|
12 |
+
- './static:/app/static'
|
lib/config.ts
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import nconf from 'nconf';
|
2 |
+
|
3 |
+
const config = nconf
|
4 |
+
.argv()
|
5 |
+
.env('__')
|
6 |
+
.file('environment', '/sandbox/config.json')
|
7 |
+
.file('defaults', 'config.json');
|
8 |
+
|
9 |
+
export default config;
|
lib/index.ts
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import express from 'express';
|
2 |
+
import path from 'path';
|
3 |
+
import routes from './route';
|
4 |
+
|
5 |
+
const app = express.Router();
|
6 |
+
|
7 |
+
app.get('/healthcheck', (_req, res) => res.status(200).send('OK'));
|
8 |
+
|
9 |
+
app.use('/api', routes);
|
10 |
+
|
11 |
+
app.use('/', express.static(path.join(__dirname, '../static')));
|
12 |
+
|
13 |
+
export default app;
|
lib/logging.ts
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { createLogger, format, transports } from 'winston';
|
2 |
+
import config from './config';
|
3 |
+
|
4 |
+
const level = config.get('log:level') || 'info';
|
5 |
+
|
6 |
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
7 |
+
export default (_name: string) =>
|
8 |
+
createLogger({
|
9 |
+
level,
|
10 |
+
format: format.simple(),
|
11 |
+
transports: [new transports.Console()],
|
12 |
+
});
|
lib/route/index.ts
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import express from 'express';
|
2 |
+
|
3 |
+
const router = express.Router();
|
4 |
+
|
5 |
+
router.get('/', (_req, res) => res.status(200).send('OK'));
|
6 |
+
|
7 |
+
export default router;
|
lib/server.ts
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import express from 'express';
|
2 |
+
import indexRoutes from './index';
|
3 |
+
import config from './config';
|
4 |
+
import logging from './logging';
|
5 |
+
|
6 |
+
const log = logging('server');
|
7 |
+
|
8 |
+
const app = express();
|
9 |
+
app.use(indexRoutes);
|
10 |
+
|
11 |
+
const port = parseInt(config.get('server:port') || '7860', 10);
|
12 |
+
app.listen(port, async () => {
|
13 |
+
log.debug(
|
14 |
+
`Huggingface readme app listening on port ${port}: go to http://localhost:${port}/`
|
15 |
+
);
|
16 |
+
});
|
package-lock.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
package.json
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "huggingface-readme",
|
3 |
+
"version": "0.0.1",
|
4 |
+
"author": "[email protected]",
|
5 |
+
"description": "Readme page for hikari systems on huggingface",
|
6 |
+
"scripts": {
|
7 |
+
"test": "jest -i",
|
8 |
+
"testci": "jest --ci --bail -i",
|
9 |
+
"lint": "eslint ./lib",
|
10 |
+
"build": "rm -rf ./es5 && tsc",
|
11 |
+
"watch": "tsc --watch",
|
12 |
+
"start": "node es5/server.js",
|
13 |
+
"develop": "nodemon es5/server.js"
|
14 |
+
},
|
15 |
+
"dependencies": {
|
16 |
+
"@types/express-serve-static-core": "^4.17.43",
|
17 |
+
"dotenv": "^16.4.5",
|
18 |
+
"express": "^4.18.2",
|
19 |
+
"nconf": "^0.12.1",
|
20 |
+
"winston": "^3.11.0"
|
21 |
+
},
|
22 |
+
"devDependencies": {
|
23 |
+
"@tsconfig/node20": "^20.1.2",
|
24 |
+
"@types/express": "^4.17.21",
|
25 |
+
"@types/jest": "^29.5.12",
|
26 |
+
"@types/node": "^20",
|
27 |
+
"@types/uuid": "^9.0.8",
|
28 |
+
"@typescript-eslint/eslint-plugin": "^6.19.1",
|
29 |
+
"@typescript-eslint/parser": "^6.19.1",
|
30 |
+
"eslint": "^7.20.0",
|
31 |
+
"eslint-config-airbnb-base": "^15.0.0",
|
32 |
+
"eslint-config-prettier": "^7.2.0",
|
33 |
+
"eslint-import-resolver-typescript": "^2.3.0",
|
34 |
+
"eslint-plugin-import": "^2.22.1",
|
35 |
+
"eslint-plugin-prettier": "^3.3.1",
|
36 |
+
"jest": "^27.5.1",
|
37 |
+
"jest-watch-typeahead": "^1.0.0",
|
38 |
+
"prettier": "^2.6.1",
|
39 |
+
"typescript": "^5.3.3"
|
40 |
+
}
|
41 |
+
}
|
static/index.html
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<title>Hikari Systems on Huggingface</title>
|
5 |
+
</head>
|
6 |
+
<body>
|
7 |
+
<h1>Welcome to Hikari Systems</h1>
|
8 |
+
</body>
|
9 |
+
</html>
|
tsconfig.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"extends": "@tsconfig/node20/tsconfig.json",
|
3 |
+
"rootDir": ".",
|
4 |
+
"compilerOptions": {
|
5 |
+
"strict": false,
|
6 |
+
"esModuleInterop": true,
|
7 |
+
"outDir": "./es5"
|
8 |
+
},
|
9 |
+
"include": ["lib/**/*"]
|
10 |
+
}
|