Move to Scalingo
parent
8442053d9d
commit
6611c92f5e
|
@ -95,7 +95,7 @@ jobs:
|
|||
with:
|
||||
path: '**/node_modules'
|
||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}-v2
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn install --immutable
|
||||
env:
|
||||
# Secrets of all kinds for fetching stats & releases
|
||||
GITHUB_API_SECRET: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
@ -119,7 +119,7 @@ jobs:
|
|||
with:
|
||||
path: '**/node_modules'
|
||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}-v2
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn install --immutable
|
||||
- name: Build API
|
||||
run: yarn workspace api build
|
||||
- uses: actions/upload-artifact@v2
|
||||
|
@ -130,7 +130,7 @@ jobs:
|
|||
if-no-files-found: error
|
||||
|
||||
deploy-preview:
|
||||
needs: [build, build-storybook, build-api, deploy-context]
|
||||
needs: [build, build-storybook, deploy-context]
|
||||
runs-on: ubuntu-18.04
|
||||
if: needs.deploy-context.outputs.env-name != 'master'
|
||||
strategy:
|
||||
|
@ -145,12 +145,8 @@ jobs:
|
|||
with:
|
||||
name: static-storybook
|
||||
path: dist/dev/storybook
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: static-api
|
||||
path: dist/netlify/functions/api
|
||||
- id: deploy-netlify
|
||||
uses: nwtgck/actions-netlify@v1.1
|
||||
uses: nwtgck/actions-netlify@v1.2
|
||||
with:
|
||||
publish-dir: './dist'
|
||||
netlify-config-path: ./netlify.toml
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
web: node -v ; yarn -v ; echo "$PORT" ; yarn workspace api run start:prod
|
|
@ -4,22 +4,21 @@
|
|||
"version": "0.0.0",
|
||||
"description": "API du site mon-entreprise",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "run validate",
|
||||
"test:type": "tsc --noEmit",
|
||||
"validate": "yarn swagger-cli validate ./source/openapi.yaml",
|
||||
"start": "yarn clean && yarn build:watch & wait-on ./dist && nodemon -d 1s ./serverless.ts",
|
||||
"build": "yarn build:openapi && yarn build:tsup",
|
||||
"build:watch": "yarn build:openapi:watch & yarn wait:openapi && yarn build:tsup:watch",
|
||||
"postinstall": "yarn build:openapi",
|
||||
"start": "yarn clean && yarn build:watch & wait-on ./dist && nodemon -d 1s ./dist/",
|
||||
"start:prod": "nodemon ./dist/index.js",
|
||||
"build": "yarn build:openapi && yarn build:ts",
|
||||
"build:watch": "yarn build:openapi:watch & yarn wait:openapi && yarn build:ts:watch",
|
||||
"build:ts": "tsc",
|
||||
"build:ts:watch": "yarn build:ts -w --preserveWatchOutput",
|
||||
"build:tsup": "tsup-node",
|
||||
"build:tsup:watch": "run build:tsup --watch",
|
||||
"postbuild": "run rename:cjs && run copy:openapi",
|
||||
"rename:cjs": "mv ./dist/index.cjs ./dist/index.js",
|
||||
"copy:openapi": "cp ./source/openapi.json ./dist",
|
||||
"wait:openapi": "wait-on ./source/openapi.json",
|
||||
"build:openapi": "yarn run swagger-cli bundle ./source/openapi.yaml > ./source/openapi.json",
|
||||
"build:openapi": "yarn run swagger-cli bundle ./source/openapi.yaml -o ./source/openapi.json",
|
||||
"build:openapi:watch": "nodemon -d 500ms -w ./source/openapi.yaml -x \"yarn build:openapi\"",
|
||||
"clean": "rm -rf dist ./source/openapi.json"
|
||||
},
|
||||
|
@ -31,29 +30,25 @@
|
|||
"dependencies": {
|
||||
"@koa/cors": "^3.3.0",
|
||||
"@koa/router": "^10.1.1",
|
||||
"@publicodes/api": "^1.0.0-beta.37",
|
||||
"@publicodes/api": "^1.0.0-beta.40",
|
||||
"koa": "^2.13.4",
|
||||
"koa-body": "^5.0.0",
|
||||
"koa-static": "^5.0.0",
|
||||
"modele-social": "workspace:^",
|
||||
"publicodes": "^1.0.0-beta.37",
|
||||
"serverless-http": "^3.0.1",
|
||||
"swagger-ui-dist": "^4.11.0"
|
||||
"modele-social": "^0.6.1",
|
||||
"publicodes": "^1.0.0-beta.40",
|
||||
"swagger-ui-dist": "^4.11.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@apidevtools/swagger-cli": "^4.0.4",
|
||||
"@netlify/functions": "^1.0.0",
|
||||
"@types/koa": "^2.13.4",
|
||||
"@types/koa-static": "^4.0.2",
|
||||
"@types/koa__cors": "^3.3.0",
|
||||
"@types/koa__router": "^8.0.11",
|
||||
"@types/node": "^17.0.32",
|
||||
"@types/node": "^17.0.35",
|
||||
"@types/swagger-ui-dist": "^3.30.1",
|
||||
"nodemon": "^2.0.16",
|
||||
"serverless-http": "^3.0.1",
|
||||
"ts-node": "^10.7.0",
|
||||
"tsup": "^5.12.8",
|
||||
"typescript": "4.7.1-rc",
|
||||
"ts-node": "^10.8.0",
|
||||
"typescript": "^4.7.2",
|
||||
"wait-on": "^6.0.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* eslint-disable no-undef */
|
||||
window.onload = function () {
|
||||
window.ui = SwaggerUIBundle({
|
||||
url: '/v1/openapi.json',
|
||||
url: '/api/v1/openapi.json',
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
import serverless from 'serverless-http'
|
||||
import { app } from './source/index.cjs'
|
||||
|
||||
const handler = serverless(app, {
|
||||
provider: 'aws',
|
||||
})
|
||||
|
||||
export { handler }
|
|
@ -1,21 +1,14 @@
|
|||
import cors from '@koa/cors'
|
||||
import Router from '@koa/router'
|
||||
// @ts-ignore
|
||||
import { koaMiddleware as publicodesAPI } from '@publicodes/api'
|
||||
import { readFileSync } from 'fs'
|
||||
import Koa from 'koa'
|
||||
// @ts-ignore
|
||||
import rules from 'modele-social'
|
||||
import path from 'path'
|
||||
// @ts-ignore
|
||||
import Engine from 'publicodes'
|
||||
// @ts-ignore
|
||||
import openapi from './openapi.json' assert { type: 'json' }
|
||||
import { docRoutes } from './route/doc.js'
|
||||
// @ts-ignore
|
||||
import { openapiRoutes } from './route/openapi.js'
|
||||
|
||||
type State = Koa.DefaultState
|
||||
|
||||
type Context = Koa.DefaultContext
|
||||
|
||||
const app = new Koa<State, Context>()
|
||||
|
@ -25,20 +18,17 @@ app.use(cors())
|
|||
|
||||
const apiRoutes = publicodesAPI(() => new Engine(rules))
|
||||
|
||||
const openapi = JSON.parse(
|
||||
// eslint-disable-next-line no-undef
|
||||
readFileSync(path.resolve(__dirname, 'openapi.json'), { encoding: 'utf8' })
|
||||
) as Record<string, unknown>
|
||||
router.use('/api/v1', apiRoutes, docRoutes(), openapiRoutes(openapi))
|
||||
|
||||
app.use(router.routes())
|
||||
app.use(router.allowedMethods())
|
||||
app.use((ctx) => {
|
||||
ctx.redirect('/api/v1/doc/')
|
||||
})
|
||||
|
||||
const port = 3004
|
||||
const port = process.env.PORT || 3004
|
||||
|
||||
app.listen(port, function () {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('listening on port:', port)
|
||||
})
|
||||
|
||||
export { app }
|
|
@ -3,6 +3,9 @@ openapi: 3.0.0
|
|||
info:
|
||||
title: Mon-entreprise API
|
||||
version: beta
|
||||
description: Cet API expose les règles Publicodes de [mon-entrprise](https://mon-entreprise.urssaf.fr/).
|
||||
description: Cet API expose les règles Publicodes de [mon-entreprise](https://mon-entreprise.urssaf.fr/).
|
||||
|
||||
servers:
|
||||
- url: https://test-api.osc-fr1.scalingo.io/api/v1/
|
||||
|
||||
paths: {}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
// "incremental": true, // disabled for tsup, see https://github.com/egoist/tsup/issues/615 for implementation status
|
||||
"incremental": true,
|
||||
"target": "ES2020",
|
||||
"module": "NodeNext",
|
||||
"outDir": "dist",
|
||||
|
@ -35,6 +35,6 @@
|
|||
"ts-node": {
|
||||
"esm": true
|
||||
},
|
||||
"include": ["source", "serverless.ts", "tsup.config.ts"],
|
||||
"include": ["source"],
|
||||
"exclude": ["**/node_modules", "**/dist", "**/*.test.*"]
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
import { defineConfig } from 'tsup'
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
entry: {
|
||||
index: 'serverless.ts',
|
||||
},
|
||||
format: ['cjs'],
|
||||
target: 'es2020',
|
||||
clean: true,
|
||||
dts: true,
|
||||
onSuccess: 'yarn postbuild',
|
||||
},
|
||||
])
|
|
@ -6,7 +6,7 @@
|
|||
"url": "https://github.com/betagouv/mon-entreprise.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.16.1"
|
||||
"node": "^16"
|
||||
},
|
||||
"workspaces": [
|
||||
"modele-social",
|
||||
|
@ -16,6 +16,7 @@
|
|||
],
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"scalingo-postbuild": "echo 'yarn workspaces focus api && yarn workspace api run build' ; yarn workspaces focus api && yarn workspace api run build",
|
||||
"lint:eslintrc": "npx eslint-config-prettier .eslintrc.cjs",
|
||||
"lint:eslint": "NODE_OPTIONS='--max-old-space-size=4096' eslint .",
|
||||
"lint:eslint:fix": "yarn lint:eslint --fix",
|
||||
|
|
|
@ -3,15 +3,11 @@ for = "/*"
|
|||
[headers.values]
|
||||
Content-Security-Policy = "default-src 'self' mon-entreprise.fr; style-src 'self' 'unsafe-inline' mon-entreprise.zammad.com; connect-src 'self' *.incubateur.net raw.githubusercontent.com tm.urssaf.fr mon-entreprise.zammad.com api.recherche-entreprises.fabrique.social.gouv.fr geo.api.gouv.fr *.algolia.net *.algolianet.com; form-action 'self' *.sibforms.com *.incubateur.net mon-entreprise.zammad.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' tm.urssaf.fr *.incubateur.net stonly.com code.jquery.com mon-entreprise.zammad.com polyfill.io; img-src 'self' data: tm.urssaf.fr user-images.githubusercontent.com; frame-src 'self' https://www.youtube-nocookie.com https://codesandbox.io https://place-des-entreprises.beta.gouv.fr https://reso-staging.osc-fr1.scalingo.io"
|
||||
|
||||
[functions]
|
||||
directory = "netlify/functions"
|
||||
included_files = ["netlify/functions/api/*.json"]
|
||||
external_node_modules = ["@publicodes/api"]
|
||||
|
||||
## API proxy
|
||||
[[redirects]]
|
||||
from = "/api/*"
|
||||
to = "/.netlify/functions/api/:splat"
|
||||
to = "https://test-api.osc-fr1.scalingo.io/api/:splat"
|
||||
status = 200
|
||||
|
||||
## Twemoji proxy for client privacy #1219
|
||||
|
|
Loading…
Reference in New Issue