Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/restructure api #6664

Merged
merged 4 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/make_docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ createDirIfNotExists('../out/doc/api')



exec(`asciidoctor -D ../out/doc ../doc/index.adoc */**.adoc -a VERSION=${VERSION}`)
exec(`asciidoctor -D ../out/doc ../doc/index.adoc ../*/**.adoc -a VERSION=${VERSION}`)
exec(`asciidoctor -D ../out/doc/api ../doc/api/*.adoc -a VERSION=${VERSION}`)

copyFolderSync('../doc/public/', '../out/doc/')
30 changes: 30 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/ep.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
"expressCreateServer": "ep_etherpad-lite/node/hooks/express/errorhandling"
}
},
{
"name": "restApi",
"hooks": {
"expressCreateServer": "ep_etherpad-lite/node/handler/RestAPI"
}
},
{
"name": "socketio",
"hooks": {
Expand Down
18 changes: 9 additions & 9 deletions src/node/handler/APIHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import {MapArrayType} from "../types/MapType";
const api = require('../db/API');
const padManager = require('../db/PadManager');
import createHTTPError from 'http-errors';
import {Http2ServerRequest, Http2ServerResponse} from "node:http2";
import {Http2ServerRequest} from "node:http2";
import {publicKeyExported} from "../security/OAuth2Provider";
import {jwtVerify} from "jose";
import {apikey} from './APIKeyHandler'
import {APIFields, apikey} from './APIKeyHandler'
// a list of all functions
const version:MapArrayType<any> = {};

Expand Down Expand Up @@ -141,20 +141,20 @@ version['1.3.0'] = {
setText: ['padID', 'text', 'authorId'],
};


version['2.2.2'] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why version 2.2.2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I first wanted to integrate the changes but realized that the old config is pretty much deprecated and it is better to just remove the old stuff then building on top of deprecated code.

...version['1.3.0'],

}


// set the latest available API version here
exports.latestApiVersion = '1.3.0';

// exports the versions so it can be used by the new Swagger endpoint
exports.version = version;


type APIFields = {
apikey: string;
api_key: string;
padID: string;
padName: string;
authorization: string;
}

/**
* Handles an HTTP API call
Expand Down
10 changes: 10 additions & 0 deletions src/node/handler/APIKeyHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ const settings = require('../utils/Settings');

const apiHandlerLogger = log4js.getLogger('APIHandler');



export type APIFields = {
apikey: string;
api_key: string;
padID: string;
padName: string;
authorization: string;
}

// ensure we have an apikey
export let apikey:string|null = null;
const apikeyFilename = absolutePaths.makeAbsolute(argv.apikey || './APIKEY.txt');
Expand Down
Loading
Loading