forked from mirror/misskey
Pre-render ReDoc
redoc-cliはexpandResponsesは200のみとすると数値と認識されてしまい設定できないため202,204という指定にしています
This commit is contained in:
parent
9e9d378bf1
commit
795fb0eb60
@ -15,7 +15,7 @@
|
|||||||
"ormconfig": "node ./built/ormconfig.js",
|
"ormconfig": "node ./built/ormconfig.js",
|
||||||
"migrate": "ts-node ./node_modules/typeorm/cli.js migration:run",
|
"migrate": "ts-node ./node_modules/typeorm/cli.js migration:run",
|
||||||
"migrateandstart": "npm run migrate && npm run start",
|
"migrateandstart": "npm run migrate && npm run start",
|
||||||
"build": "webpack && gulp build",
|
"build": "webpack && gulp build && npm run redoc",
|
||||||
"webpack": "webpack",
|
"webpack": "webpack",
|
||||||
"watch": "webpack --watch",
|
"watch": "webpack --watch",
|
||||||
"gulp": "gulp build",
|
"gulp": "gulp build",
|
||||||
@ -23,7 +23,8 @@
|
|||||||
"cleanall": "gulp cleanall",
|
"cleanall": "gulp cleanall",
|
||||||
"lint": "tslint 'src/**/*.ts'",
|
"lint": "tslint 'src/**/*.ts'",
|
||||||
"test": "cross-env TS_NODE_FILES=true gulp test",
|
"test": "cross-env TS_NODE_FILES=true gulp test",
|
||||||
"format": "gulp format"
|
"format": "gulp format",
|
||||||
|
"redoc": "node ./built/tools/ make-api-json && redoc-cli bundle built/client/assets/api.json -o built/client/assets/redoc.html --options.expandResponses '200,204' --options.expandSingleSchemaField true --cdn true"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"https-proxy-agent": "^3.0.0",
|
"https-proxy-agent": "^3.0.0",
|
||||||
@ -202,6 +203,7 @@
|
|||||||
"reconnecting-websocket": "4.4.0",
|
"reconnecting-websocket": "4.4.0",
|
||||||
"redis": "3.0.2",
|
"redis": "3.0.2",
|
||||||
"redis-lock": "0.1.4",
|
"redis-lock": "0.1.4",
|
||||||
|
"redoc-cli": "0.9.7",
|
||||||
"reflect-metadata": "0.1.13",
|
"reflect-metadata": "0.1.13",
|
||||||
"rename": "1.0.4",
|
"rename": "1.0.4",
|
||||||
"request": "2.88.2",
|
"request": "2.88.2",
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Misskey API</title>
|
|
||||||
<!-- needed for adaptive design -->
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
|
|
||||||
|
|
||||||
<!--
|
|
||||||
ReDoc doesn't change outer page styles
|
|
||||||
-->
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<redoc spec-url='/api.json'></redoc>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -15,7 +15,6 @@ import * as MarkdownIt from 'markdown-it';
|
|||||||
|
|
||||||
import packFeed from './feed';
|
import packFeed from './feed';
|
||||||
import { fetchMeta } from '../../misc/fetch-meta';
|
import { fetchMeta } from '../../misc/fetch-meta';
|
||||||
import { genOpenapiSpec } from '../api/openapi/gen-spec';
|
|
||||||
import config from '../../config';
|
import config from '../../config';
|
||||||
import { Users, Notes, Emojis, UserProfiles, Pages } from '../../models';
|
import { Users, Notes, Emojis, UserProfiles, Pages } from '../../models';
|
||||||
import parseAcct from '../../misc/acct/parse';
|
import parseAcct from '../../misc/acct/parse';
|
||||||
@ -97,13 +96,15 @@ router.get('/api-doc', async ctx => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.get('/api.json', async ctx => {
|
||||||
|
await send(ctx as any, '/assets/api.json', {
|
||||||
|
root: client
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// URL preview endpoint
|
// URL preview endpoint
|
||||||
router.get('/url', require('./url-preview'));
|
router.get('/url', require('./url-preview'));
|
||||||
|
|
||||||
router.get('/api.json', async ctx => {
|
|
||||||
ctx.body = genOpenapiSpec();
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get('/docs.json', async ctx => {
|
router.get('/docs.json', async ctx => {
|
||||||
const lang = ctx.query.lang;
|
const lang = ctx.query.lang;
|
||||||
if (!Object.keys(locales).includes(lang)) {
|
if (!Object.keys(locales).includes(lang)) {
|
||||||
|
@ -14,17 +14,19 @@ async function main(name: string, url: string, alias?: string): Promise<any> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
export default () => {
|
||||||
const name = args[0];
|
const args = process.argv.slice(3);
|
||||||
const url = args[1];
|
const name = args[0];
|
||||||
|
const url = args[1];
|
||||||
if (!name) throw new Error('require name');
|
|
||||||
if (!url) throw new Error('require url');
|
if (!name) throw new Error('require name');
|
||||||
|
if (!url) throw new Error('require url');
|
||||||
main(name, url).then(() => {
|
|
||||||
console.log('success');
|
main(name, url).then(() => {
|
||||||
process.exit(0);
|
console.log('success');
|
||||||
}).catch(e => {
|
process.exit(0);
|
||||||
console.warn(e);
|
}).catch(e => {
|
||||||
process.exit(1);
|
console.warn(e);
|
||||||
});
|
process.exit(1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
8
src/tools/index.ts
Normal file
8
src/tools/index.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { initDb } from '../db/postgre';
|
||||||
|
import 'reflect-metadata';
|
||||||
|
|
||||||
|
console.log('Connecting DB...')
|
||||||
|
initDb().then(() => {
|
||||||
|
console.log('Connedted!')
|
||||||
|
require(`./${process.argv[2]}`).default();
|
||||||
|
});
|
9
src/tools/make-api-json.ts
Normal file
9
src/tools/make-api-json.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { writeFileSync } from 'fs';
|
||||||
|
import { join } from 'path';
|
||||||
|
import { genOpenapiSpec } from '../server/api/openapi/gen-spec';
|
||||||
|
|
||||||
|
export default () => {
|
||||||
|
writeFileSync(join(__dirname, '../../built/client/assets/api.json'), JSON.stringify(genOpenapiSpec()));
|
||||||
|
console.log('Done!');
|
||||||
|
process.exit(0);
|
||||||
|
};
|
@ -21,12 +21,14 @@ async function main(username: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
export default () => {
|
||||||
|
const args = process.argv.slice(3);
|
||||||
|
|
||||||
main(args[0]).then(() => {
|
main(args[0]).then(() => {
|
||||||
console.log('Success');
|
console.log('Success');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
console.error(`Error: ${e.message || e}`);
|
console.error(`Error: ${e.message || e}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
@ -4,11 +4,15 @@ async function main(uri: string): Promise<any> {
|
|||||||
return await updateQuestion(uri);
|
return await updateQuestion(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
export default () => {
|
||||||
const uri = args[0];
|
const args = process.argv.slice(3);
|
||||||
|
const uri = args[0];
|
||||||
main(uri).then(result => {
|
|
||||||
console.log(`Done: ${result}`);
|
main(uri).then(result => {
|
||||||
}).catch(e => {
|
console.log(`Done: ${result}`);
|
||||||
console.warn(e);
|
process.exit(0);
|
||||||
});
|
}).catch(e => {
|
||||||
|
console.warn(e);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -6,22 +6,26 @@ async function main(acct: string): Promise<any> {
|
|||||||
await resolveUser(username, host, {}, true);
|
await resolveUser(username, host, {}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get args
|
export default () => {
|
||||||
const args = process.argv.slice(2);
|
// get args
|
||||||
let acct = args[0];
|
const args = process.argv.slice(3);
|
||||||
|
let acct = args[0];
|
||||||
// normalize args
|
|
||||||
acct = acct.replace(/^@/, '');
|
// normalize args
|
||||||
|
acct = acct.replace(/^@/, '');
|
||||||
// check args
|
|
||||||
if (!acct.match(/^\w+@\w/)) {
|
// check args
|
||||||
throw `Invalid acct format. Valid format are user@host`;
|
if (!acct.match(/^\w+@\w/)) {
|
||||||
|
throw `Invalid acct format. Valid format are user@host`;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`resync ${acct}`);
|
||||||
|
|
||||||
|
main(acct).then(() => {
|
||||||
|
console.log('Done');
|
||||||
|
process.exit(0);
|
||||||
|
}).catch(e => {
|
||||||
|
console.warn(e);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`resync ${acct}`);
|
|
||||||
|
|
||||||
main(acct).then(() => {
|
|
||||||
console.log('Done');
|
|
||||||
}).catch(e => {
|
|
||||||
console.warn(e);
|
|
||||||
});
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { Users, Signins } from '../models';
|
import { Users, Signins } from '../models';
|
||||||
|
|
||||||
// node built/tools/show-signin-history username
|
// node built/tools/ show-signin-history username
|
||||||
// => {Success} {Date} {IPAddrsss}
|
// => {Success} {Date} {IPAddrsss}
|
||||||
|
|
||||||
// node built/tools/show-signin-history username user-agent,x-forwarded-for
|
// node built/tools/ show-signin-history username user-agent,x-forwarded-for
|
||||||
// with user-agent and x-forwarded-for
|
// with user-agent and x-forwarded-for
|
||||||
|
|
||||||
// node built/tools/show-signin-history username all
|
// node built/tools/ show-signin-history username all
|
||||||
// with full request headers
|
// with full request headers
|
||||||
|
|
||||||
async function main(username: string, headers?: string[]) {
|
async function main(username: string, headers?: string[]) {
|
||||||
@ -35,22 +35,25 @@ async function main(username: string, headers?: string[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get args
|
export default () => {
|
||||||
const args = process.argv.slice(2);
|
// get args
|
||||||
|
const args = process.argv.slice(3);
|
||||||
|
|
||||||
let username = args[0];
|
let username = args[0];
|
||||||
let headers: string[] | undefined;
|
let headers: string[] | undefined;
|
||||||
|
|
||||||
if (args[1] != null) {
|
if (args[1] != null) {
|
||||||
headers = args[1].split(/,/).map(header => header.toLowerCase());
|
headers = args[1].split(/,/).map(header => header.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
// normalize args
|
||||||
|
username = username.replace(/^@/, '');
|
||||||
|
|
||||||
|
main(username, headers).then(() => {
|
||||||
|
process.exit(0);
|
||||||
|
}).catch(e => {
|
||||||
|
console.warn(e);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// normalize args
|
|
||||||
username = username.replace(/^@/, '');
|
|
||||||
|
|
||||||
main(username, headers).then(() => {
|
|
||||||
process.exit(0);
|
|
||||||
}).catch(e => {
|
|
||||||
console.warn(e);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
|
Loading…
Reference in New Issue
Block a user