Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

Commit f0235ef

Browse files
author
Ricardo Gomez-Ulmke
authored
Merge pull request #8 from solace-iot-team/feature-server-misc
Feature server misc
2 parents 9cc0a69 + 640baa0 commit f0235ef

File tree

35 files changed

+704
-541
lines changed

35 files changed

+704
-541
lines changed

ReleaseNotes.md

+26-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,35 @@
22

33
Solace Async API Management.
44

5+
## Version 0.0.28
6+
* [API-M Admin & Developer Portal](https://github.com/solace-iot-team/async-apim/tree/main/apim-portal): 0.0.28
7+
* [API-M Server OpenAPI](https://github.com/solace-iot-team/async-apim/blob/main/apim-server/server/common/api.yml): 0.0.14
8+
* [API-M Server](https://github.com/solace-iot-team/async-apim/tree/main/apim-server): 0.0.8
9+
10+
#### API-M Admin & Developer Portal
11+
**No Changes.**
12+
13+
#### API-M Server OpenAPI
14+
15+
**New:**
16+
- **error-id**
17+
- `serverNotOperational`: returned for api calls when server is not ready
18+
19+
#### API-M Server
20+
**New:**
21+
- **monitor**
22+
- re-initializes server after failed healthcheck
23+
- **startup/initialization**
24+
- exits server for unrecoverable errors, e.g.:
25+
- mal-formed DB connection string
26+
- DB authentication error
27+
- log of DB server and client info
28+
- bootstrap users
29+
530
## Version 0.0.27
631
* [API-M Admin & Developer Portal](https://github.com/solace-iot-team/async-apim/tree/main/apim-portal): 0.0.27
732
* [API-M Server OpenAPI](https://github.com/solace-iot-team/async-apim/blob/main/apim-server/server/common/api.yml): 0.0.13
8-
* [API-M Server](https://github.com/solace-iot-team/async-apim/tree/main/apim-server): 0.0.8
33+
* [API-M Server](https://github.com/solace-iot-team/async-apim/tree/main/apim-server): 0.0.7
934

1035
#### API-M Admin & Developer Portal
1136
**New:**

apim-portal/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "async-apim-portal",
3-
"version": "0.0.27",
3+
"version": "0.0.28",
44
"description": "Solace Async API Management Portal",
55
"repository": {
66
"type": "git",

apim-portal/src/components/APAbout/APDisplayAbout.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ export const APDisplayAbout: React.FC<IAPDisplayAboutProps> = (props: IAPDisplay
222222
);
223223
}
224224

225+
const renderDescription = () => {
226+
return (
227+
<div className="p-mb-4">
228+
Concept Portal for Solace Async API Management.
229+
</div>
230+
);
231+
}
225232
const renderComponent = (): JSX.Element => {
226233
return(
227234
<Dialog
@@ -235,6 +242,7 @@ export const APDisplayAbout: React.FC<IAPDisplayAboutProps> = (props: IAPDisplay
235242
// resizable={true}
236243
>
237244
<div className="p-m-0">
245+
{renderDescription()}
238246
{renderAdminPortalAbout()}
239247
{renderDeveloperPortalAbout()}
240248
{renderApimServerAbout()}

apim-server/.env

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
APIM_SERVER_PORT=3003
22
APIM_SERVER_MONGO_CONNECTION_STRING=mongodb://localhost:27019/?retryWrites=true&w=majority
3+
4+
# wrong format of connection string
5+
# APIM_SERVER_MONGO_CONNECTION_STRING=mongodb:/localhost:27019/?retryWrites=true&w=majority
6+
# wrong user/pwd
7+
# APIM_SERVER_MONGO_CONNECTION_STRING=mongodb://uname:pwd@localhost:27019/?retryWrites=true&w=majority
8+
39
APIM_SERVER_MONGO_DB=solace-apim-server
410
APIM_SERVER_OPENAPI_ENABLE_RESPONSE_VALIDATION=true
511
APIM_SERVER_LOGGER_APP_ID=devel-apim-server
@@ -9,4 +15,4 @@ APIM_SERVER_REQUEST_SIZE_LIMIT=100kb
915
APIM_SERVER_SECRET=mySecret
1016
APIM_SERVER_ROOT_USER=[email protected]
1117
APIM_SERVER_ROOT_USER_PWD=admin123!
12-
APIM_SERVER_DATA_PATH=./data
18+
APIM_SERVER_DATA_PATH=./data
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[
2+
{
3+
"userId": "[email protected]",
4+
"password": "[email protected]",
5+
"roles": ["apiConsumer", "apiTeam", "loginAs", "organizationAdmin", "systemAdmin"],
6+
"isActivated": true,
7+
"profile": {
8+
"first": "Master",
9+
"last": "User",
10+
"email": "[email protected]"
11+
},
12+
"memberOfOrganizations": ["apim-quickstart"]
13+
},
14+
{
15+
"userId": "[email protected]",
16+
"password": "[email protected]",
17+
"roles": ["apiConsumer"],
18+
"isActivated": true,
19+
"profile": {
20+
"first": "Api",
21+
"last": "Consumer",
22+
"email": "[email protected]"
23+
},
24+
"memberOfOrganizations": ["apim-quickstart"]
25+
},
26+
{
27+
"userId": "[email protected]",
28+
"password": "[email protected]",
29+
"roles": ["apiTeam"],
30+
"isActivated": true,
31+
"profile": {
32+
"first": "Api",
33+
"last": "Team",
34+
"email": "[email protected]"
35+
},
36+
"memberOfOrganizations": ["apim-quickstart"]
37+
},
38+
{
39+
"userId": "[email protected]",
40+
"password": "[email protected]",
41+
"roles": ["organizationAdmin"],
42+
"isActivated": true,
43+
"profile": {
44+
"first": "Org",
45+
"last": "Admin",
46+
"email": "[email protected]"
47+
},
48+
"memberOfOrganizations": ["apim-quickstart"]
49+
},
50+
{
51+
"userId": "[email protected]",
52+
"password": "[email protected]",
53+
"roles": ["systemAdmin", "loginAs"],
54+
"isActivated": true,
55+
"profile": {
56+
"first": "System",
57+
"last": "Admin",
58+
"email": "[email protected]"
59+
},
60+
"memberOfOrganizations": ["apim-quickstart"]
61+
}
62+
]

apim-server/devel/README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ brew install node@16
1212
brew unlink node
1313
brew link node@14
1414
````
15+
## Build & Run
16+
````bash
17+
npm install
18+
npm run build
19+
npm start
20+
# or
21+
npm run start:pretty
22+
````
1523

1624
## Development Build & Run
1725
### Devel Build
@@ -82,10 +90,8 @@ vi test/source.env.sh
8290
# adjust the settings for openapi & inline tests
8391
````
8492
### Run All Tests
85-
- starts server
86-
- runs all tests
87-
8893
````bash
94+
npm run dev:build
8995
npm test
9096
# with pretty print server output:
9197
npm run test:pretty

apim-server/package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apim-server/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"name": "@solace-iot-team/apim-server",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"description": "Async API Management Server",
55
"scripts": {
66
"start": "node dist/server/index.js",
7+
"start:pretty": "node dist/server/index.js | pino-pretty",
78
"build": "tsc && ts-node build.ts",
89
"dev:build:types": "ts-node dev-build-types.ts",
910
"dev:build": "ts-node dev-build-types.ts && ts-node dev-build.ts",
@@ -43,7 +44,7 @@
4344
"dotenv": "^10.0.0",
4445
"express": "^4.17.1",
4546
"express-openapi-validator": "^4.12.11",
46-
"express-requests-logger": "^3.0.4",
47+
"express-requests-logger": "^3.0.3",
4748
"form-data": "^4.0.0",
4849
"mongodb": "^4.1.0",
4950
"node-fetch": "^2.6.1",

apim-server/server/api/controllers/apsUsers/ApsUsersController.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class ApsUsersController {
1010
public static all = (req: Request, res: Response, next: NextFunction): void => {
1111
APSUsersService.all(ApiQueryHelper.getPagingInfoFromQuery(req.query), ApiQueryHelper.getSortInfoFromQuery(req.query), ApiQueryHelper.getSearchInfoFromQuery(req.query))
1212
.then( (r: TAPSListUserResponse) => {
13+
// res.status(200).type('application/json').json(r);
1314
res.status(200).json(r);
1415
})
1516
.catch( (e) => {

apim-server/server/api/controllers/examples/controller.ts

-68
This file was deleted.

apim-server/server/api/controllers/examples/router.ts

-10
This file was deleted.

apim-server/server/api/middlewares/error.handler.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,24 @@ export default function errorHandler(
2626
if(err instanceof MongoError) internalServerError = new ApiInternalServerErrorFromMongoError(err, logName);
2727
else if(err instanceof OpenApiValidatorHttpError) {
2828
internalServerError = new ApiServerErrorFromOpenApiRequestValidatorError(logName, err, req.body, ServerLogger.getRequestInfo(req));
29-
}
30-
else internalServerError = new ApiInternalServerErrorFromError(err, logName);
29+
} else internalServerError = new ApiInternalServerErrorFromError(err, logName);
3130
serverErrorHandler(internalServerError, req, res, next);
3231
}
3332
}
3433

3534
const serverErrorHandler = (apiServerError: ApiServerError, _req: Request, res: Response, _next: NextFunction) => {
3635
const funcName = 'serverErrorHandler';
3736
const logName = `${componentName}.${funcName}()`;
38-
const logEntry: TServerLogEntry = ServerLogger.createLogEntry(logName, { code: EServerStatusCodes.Api_Service_Error, message: apiServerError.message, details: apiServerError.toObject() });
37+
const logEntry: TServerLogEntry = ServerLogger.createLogEntry(logName, { code: EServerStatusCodes.API_SERVICE_ERROR, message: apiServerError.message, details: apiServerError.toObject() });
3938

4039
if(apiServerError instanceof ApiInternalServerError)
41-
ServerLogger.error(logEntry);
40+
ServerLogger.warn(logEntry);
4241
else
4342
ServerLogger.debug(logEntry);
4443

4544
for (const responseHeader of apiServerError.getAPSErrorHeaders()) {
4645
res.header(responseHeader.headerField, responseHeader.headerValue);
4746
}
48-
res.status(apiServerError.apiStatusCode).json(apiServerError.toAPSError());
47+
res.status(apiServerError.apiStatusCode).json(apiServerError.toAPSError());
4948
}
5049

apim-server/server/api/middlewares/requestLogger.ts

-16
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Request, Response, NextFunction } from 'express';
2+
import { ApiInternalServerErrorNotOperational } from '../../common/ServerError';
3+
import { EServerStatusCodes, ServerLogger } from '../../common/ServerLogger';
4+
import ServerStatus from '../../common/ServerStatus';
5+
6+
const componentName = "middleware";
7+
8+
export default function verifyServerStatus(
9+
_req: Request,
10+
_res: Response,
11+
next: NextFunction
12+
): void {
13+
const funcName = 'verifyServerStatus';
14+
const logName = `${componentName}.${funcName}()`;
15+
if(!ServerStatus.getStatus().isReady) {
16+
ServerLogger.warn(ServerLogger.createLogEntry(logName, { code: EServerStatusCodes.API_SERVICE_ERROR, message: 'server status', details: ServerStatus.getStatus() }));
17+
throw new ApiInternalServerErrorNotOperational(logName);
18+
}
19+
next();
20+
}

0 commit comments

Comments
 (0)