Skip to content

Commit fc0f27f

Browse files
committed
feat(api): create new @nivo/static & @nivo/express packages
1 parent a4dbb44 commit fc0f27f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+381
-324
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ build
1414

1515
*.lerna_backup
1616

17-
/stats
17+
/stats
18+
/api/app.js

Procfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
web: node api/build/app.js
1+
web: node api/app.js

api/app.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import express from 'express'
2+
import cors from 'cors'
3+
import bodyParser from 'body-parser'
4+
import compression from 'compression'
5+
import winston from 'winston'
6+
import expressWinston from 'express-winston'
7+
import { nivo } from '@nivo/express'
8+
9+
const app = express()
10+
11+
app.enable('trust proxy')
12+
app.set('json spaces', 4)
13+
app.use(cors())
14+
app.use(bodyParser.json())
15+
app.use(
16+
expressWinston.logger({
17+
transports: [new winston.transports.Console()],
18+
format: winston.format.combine(winston.format.colorize(), winston.format.simple()),
19+
meta: false,
20+
expressFormat: true,
21+
colorize: true,
22+
})
23+
)
24+
app.use(compression())
25+
26+
app.get('/status', (req, res) => {
27+
res.status(200).json({
28+
status: 'ok',
29+
uptime: `${process.uptime()} second(s)`,
30+
protocol: req.protocol,
31+
host: req.get('host'),
32+
env: {
33+
// @ts-ignore
34+
NODE_ENV: process.NODE_ENV,
35+
},
36+
})
37+
})
38+
39+
app.use('/nivo', nivo)
40+
41+
const port = process.env.PORT || 3030
42+
app.listen(port, () => {
43+
console.log(`nivo api listening on ${port}`)
44+
})

api/misc/README.mustache

-53
This file was deleted.

api/misc/readmeData.js

-20
This file was deleted.

api/nodemon.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"restartable": "rs",
3-
"ignore": ["node_modules/", "dist/", "coverage/"],
4-
"watch": ["src/"],
3+
"ignore": ["node_modules/"],
4+
"watch": ["app.ts"],
55
"execMap": {
66
"ts": "node -r ts-node/register"
77
},
88
"env": {
99
"NODE_ENV": "development"
1010
},
11-
"ext": "js,json,ts"
11+
"ext": "ts"
1212
}

api/package.json

+5-31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@nivo/api",
33
"version": "0.74.1",
4+
"private": true,
45
"description": "Rendering API for nivo dataviz React/d3 components",
56
"main": "src/app.js",
67
"licenses": [
@@ -18,56 +19,29 @@
1819
"node": "16.x"
1920
},
2021
"devDependencies": {
21-
"mustache": "^2.3.0",
2222
"nodemon": "^1.18.10"
2323
},
2424
"dependencies": {
25-
"@nivo/bar": "0.74.1",
26-
"@nivo/bullet": "0.74.1",
27-
"@nivo/calendar": "0.74.1",
28-
"@nivo/chord": "0.74.1",
29-
"@nivo/circle-packing": "0.74.1",
30-
"@nivo/core": "0.74.1",
31-
"@nivo/generators": "0.74.0",
32-
"@nivo/heatmap": "0.74.1",
33-
"@nivo/legends": "0.74.1",
34-
"@nivo/line": "0.74.1",
35-
"@nivo/parallel-coordinates": "0.74.1",
36-
"@nivo/pie": "0.74.1",
37-
"@nivo/radar": "0.74.1",
38-
"@nivo/sankey": "0.74.1",
39-
"@nivo/scatterplot": "0.74.1",
40-
"@nivo/stream": "0.74.1",
41-
"@nivo/sunburst": "0.74.1",
42-
"@nivo/treemap": "0.74.1",
43-
"@nivo/voronoi": "0.74.1",
44-
"@nivo/waffle": "0.74.1",
25+
"@nivo/express": "0.74.1",
4526
"@types/body-parser": "^1.19.2",
4627
"@types/cors": "^2.8.12",
4728
"@types/express": "^4.17.13",
4829
"@types/node": "^16.11.12",
49-
"@types/react": "^17.0.37",
50-
"@types/react-dom": "^17.0.11",
51-
"@types/uuid": "^8.3.3",
5230
"body-parser": "^1.17.2",
5331
"compression": "^1.7.0",
5432
"cors": "2.8.5",
5533
"express": "4.17.1",
5634
"express-winston": "4.2.0",
57-
"joi": "17.5.0",
58-
"lodash": "^4.17.21",
5935
"react": "^17.0.2",
6036
"react-dom": "^17.0.2",
6137
"ts-node": "^10.4.0",
6238
"typescript": "^4.5.4",
63-
"uuid": "^3.1.0",
6439
"winston": "3.3.3"
6540
},
6641
"scripts": {
67-
"readme": "node misc/readmeData.js | mustache - misc/README.mustache > README.md",
68-
"start": "node build/app.ts",
69-
"dev": "nodemon src/app.ts",
70-
"build": "rm -rf build && tsc"
42+
"start": "yarn build && node app.js",
43+
"dev": "nodemon app.ts",
44+
"build": "tsc"
7145
},
7246
"publishConfig": {
7347
"access": "public"

api/src/app.ts

-98
This file was deleted.

api/src/mapping/index.ts

-32
This file was deleted.

api/tsconfig.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"compilerOptions": {
3-
"module": "commonjs",
43
"target": "es5",
5-
"rootDir": "./src",
6-
"outDir": "build",
4+
"rootDir": ".",
5+
"module": "commonjs",
6+
"moduleResolution": "node",
77
"esModuleInterop": true,
88
"skipLibCheck": true,
99
"forceConsistentCasingInFileNames": true
10-
}
10+
},
11+
"include": ["*.ts"]
1112
}

packages/express/LICENSE.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) Raphaël Benitte
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

packages/express/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `@nivo/express`
2+
3+
[![version](https://img.shields.io/npm/v/@nivo/express.svg?style=flat-square)](https://www.npmjs.com/package/@nivo/express)

0 commit comments

Comments
 (0)