Skip to content

Commit

Permalink
feat(api): create new @nivo/static & @nivo/express packages
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc committed Dec 17, 2021
1 parent a4dbb44 commit fc0f27f
Show file tree
Hide file tree
Showing 44 changed files with 381 additions and 324 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -14,4 +14,5 @@ build

*.lerna_backup

/stats
/stats
/api/app.js
2 changes: 1 addition & 1 deletion Procfile
@@ -1 +1 @@
web: node api/build/app.js
web: node api/app.js
44 changes: 44 additions & 0 deletions api/app.ts
@@ -0,0 +1,44 @@
import express from 'express'
import cors from 'cors'
import bodyParser from 'body-parser'
import compression from 'compression'
import winston from 'winston'
import expressWinston from 'express-winston'
import { nivo } from '@nivo/express'

const app = express()

app.enable('trust proxy')
app.set('json spaces', 4)
app.use(cors())
app.use(bodyParser.json())
app.use(
expressWinston.logger({
transports: [new winston.transports.Console()],
format: winston.format.combine(winston.format.colorize(), winston.format.simple()),
meta: false,
expressFormat: true,
colorize: true,
})
)
app.use(compression())

app.get('/status', (req, res) => {
res.status(200).json({
status: 'ok',
uptime: `${process.uptime()} second(s)`,
protocol: req.protocol,
host: req.get('host'),
env: {
// @ts-ignore
NODE_ENV: process.NODE_ENV,
},
})
})

app.use('/nivo', nivo)

const port = process.env.PORT || 3030
app.listen(port, () => {
console.log(`nivo api listening on ${port}`)
})
53 changes: 0 additions & 53 deletions api/misc/README.mustache

This file was deleted.

20 changes: 0 additions & 20 deletions api/misc/readmeData.js

This file was deleted.

6 changes: 3 additions & 3 deletions api/nodemon.json
@@ -1,12 +1,12 @@
{
"restartable": "rs",
"ignore": ["node_modules/", "dist/", "coverage/"],
"watch": ["src/"],
"ignore": ["node_modules/"],
"watch": ["app.ts"],
"execMap": {
"ts": "node -r ts-node/register"
},
"env": {
"NODE_ENV": "development"
},
"ext": "js,json,ts"
"ext": "ts"
}
36 changes: 5 additions & 31 deletions api/package.json
@@ -1,6 +1,7 @@
{
"name": "@nivo/api",
"version": "0.74.1",
"private": true,
"description": "Rendering API for nivo dataviz React/d3 components",
"main": "src/app.js",
"licenses": [
Expand All @@ -18,56 +19,29 @@
"node": "16.x"
},
"devDependencies": {
"mustache": "^2.3.0",
"nodemon": "^1.18.10"
},
"dependencies": {
"@nivo/bar": "0.74.1",
"@nivo/bullet": "0.74.1",
"@nivo/calendar": "0.74.1",
"@nivo/chord": "0.74.1",
"@nivo/circle-packing": "0.74.1",
"@nivo/core": "0.74.1",
"@nivo/generators": "0.74.0",
"@nivo/heatmap": "0.74.1",
"@nivo/legends": "0.74.1",
"@nivo/line": "0.74.1",
"@nivo/parallel-coordinates": "0.74.1",
"@nivo/pie": "0.74.1",
"@nivo/radar": "0.74.1",
"@nivo/sankey": "0.74.1",
"@nivo/scatterplot": "0.74.1",
"@nivo/stream": "0.74.1",
"@nivo/sunburst": "0.74.1",
"@nivo/treemap": "0.74.1",
"@nivo/voronoi": "0.74.1",
"@nivo/waffle": "0.74.1",
"@nivo/express": "0.74.1",
"@types/body-parser": "^1.19.2",
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"@types/node": "^16.11.12",
"@types/react": "^17.0.37",
"@types/react-dom": "^17.0.11",
"@types/uuid": "^8.3.3",
"body-parser": "^1.17.2",
"compression": "^1.7.0",
"cors": "2.8.5",
"express": "4.17.1",
"express-winston": "4.2.0",
"joi": "17.5.0",
"lodash": "^4.17.21",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"ts-node": "^10.4.0",
"typescript": "^4.5.4",
"uuid": "^3.1.0",
"winston": "3.3.3"
},
"scripts": {
"readme": "node misc/readmeData.js | mustache - misc/README.mustache > README.md",
"start": "node build/app.ts",
"dev": "nodemon src/app.ts",
"build": "rm -rf build && tsc"
"start": "yarn build && node app.js",
"dev": "nodemon app.ts",
"build": "tsc"
},
"publishConfig": {
"access": "public"
Expand Down
98 changes: 0 additions & 98 deletions api/src/app.ts

This file was deleted.

32 changes: 0 additions & 32 deletions api/src/mapping/index.ts

This file was deleted.

9 changes: 5 additions & 4 deletions api/tsconfig.json
@@ -1,11 +1,12 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"rootDir": "./src",
"outDir": "build",
"rootDir": ".",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
},
"include": ["*.ts"]
}
19 changes: 19 additions & 0 deletions packages/express/LICENSE.md
@@ -0,0 +1,19 @@
Copyright (c) Raphaël Benitte

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions packages/express/README.md
@@ -0,0 +1,3 @@
# `@nivo/express`

[![version](https://img.shields.io/npm/v/@nivo/express.svg?style=flat-square)](https://www.npmjs.com/package/@nivo/express)

0 comments on commit fc0f27f

Please sign in to comment.