Skip to content

Commit d4840f9

Browse files
committed
1.0.0 release
1 parent 53ea802 commit d4840f9

File tree

7 files changed

+157
-426
lines changed

7 files changed

+157
-426
lines changed

.eslintrc.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
module.exports = {
22
parser: '@typescript-eslint/parser',
3-
/*parserOptions: {
3+
parserOptions: {
44
project:'./tsconfig.json'
5-
},*/
5+
},
66
plugins: ['@typescript-eslint'],
7-
extends: ['plugin:@typescript-eslint/recommended'],
7+
extends: [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/eslint-recommended",
10+
"plugin:@typescript-eslint/recommended"
11+
],
812
rules: {
913
"indent": "off",
10-
"semi": "error",
14+
"@typescript-eslint/brace-style": ["error", "stroustrup"],
1115
"@typescript-eslint/camelcase": "off",
1216
"@typescript-eslint/indent": ["error", 2],
13-
"@typescript-eslint/no-explicit-any": "off"
14-
// not yet released - "@typescript-eslint/semi": ["error"]
17+
"@typescript-eslint/semi": ["error"]
1518
}
16-
}
19+
}

CHANGELOG.md

+1-24
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,4 @@
11
# Changelog
22

3-
## v1.3.3
4-
* Add missing cookie-parser dependency
5-
6-
## v1.3.1
7-
* Add back in `app.expressListen`
8-
* Make `app.listen` to be equivalent to v1.2.1 `app.listen` functionality
9-
* Remove `app.cogListen` as it's equivalent to `app.listen`
10-
* Use `utf-8` instead of `ascii` when reading the cog.json file
11-
12-
## v1.3.0
13-
* Rewrite module to use TypeScript
14-
* Added `app.cogListen` function which incorporates the old overriden `app.listen` functionality.
15-
* Remove `app.express` and `app.express_listen`. Simply import `express` or use `app.listen` instead.
16-
17-
## v1.2.1
18-
* Fix undefined reference to logger.log (should be logger.info) when using @cisl/logger
19-
20-
## v1.2.0
21-
* Use @cisl/logger if installed over console
22-
23-
## v1.1.0
24-
* Added [ejs](https://ejs.co/) as the view engine
25-
263
## v1.0.0
27-
* Initial Release
4+
* Initial Release (as @cisl/express)

LICENSE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
MIT License
22

3-
Copyright (c) 2019 CISL
3+
Copyright (c) 2019 Cognitive and Immersive Systems Lab
44

55
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:
66

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

9-
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.
9+
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.

README.md

+35-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# @cisl/express
22

3-
An opinionated wrapper around the popular [express](https://expressjs.com/) library as
4-
well as [socket.io](https://socket.io/).
3+
An opinionated wrapper around the popular [express](https://expressjs.com/) and [websockets/ws](https://github.com/websockets/ws) libraries. It assumes that you are running
4+
an application with a `cog.json` file.
55

66
The library assumes that you want to use `cookie-parser`, `body-parser` (namely JSON),
77
`json spaces` set to 2, and use `ejs` as the view engine. Finally, the port is
@@ -12,50 +12,71 @@ used from the `cog.json` file.
1212
npm install @cisl/express
1313
```
1414
## Usage
15+
In straight JS:
1516
```js
1617
const express = require('@cisl/express');
17-
// or typescript
18-
import app from '@cisl/express';
18+
const app = express();
19+
app.listen();
20+
```
1921

22+
or in TypeScript:
23+
```typescript
24+
// or typescript
25+
import express from '@cisl/express';
2026
const app = express();
27+
2128
app.listen();
2229
```
30+
The `listen` method above does not accept any parameters, and will automatically use the
31+
port specified in the `cog.json` file that should exist in current working directory when
32+
running the above.
2333

24-
and then it can be used the same as a regular express object:
34+
After creating the object, it can be used as a regular express app:
2535
```js
2636
app.get('/', (req, res) => {
2737
res.json({'msg': 'Hello World'});
2838
});
2939
```
3040

31-
as well as accessing the attached socket.io instance:
41+
as well as accessing the attached WebSocket server:
3242
```js
33-
app.socketio.on('connection', (socket) => {
43+
app.wsServer.on('connection', (socket) => {
3444
console.log('a user connected');
45+
socket.on('message', data => {
46+
console.log(`Received: ${data}`);
47+
socket.send('pong');
48+
});
3549
});
3650
```
3751

38-
If you want to disable the socket.io instance, pass in `{socketio: false}` to the `express`
39-
function.
52+
The available objects off the original (in addition to the normal express stuff) is:
53+
* `expressListen` - original express listen method, should largely not be necessary/used over `listen()`
54+
* `httpServer` - the underlying `HttpServer` instance
55+
* `wsServer` - the underlying `WebSocket.Server` instance
4056

41-
If you need the original listen method, it can be accessed through `app.expressListen`.
42-
Socket.io is expressed through `app.socketio`.
4357

44-
Additionally, the package will automatically add a `/test` GET route that returns
58+
Finally, the package will automatically add a `/test` GET route that returns
4559
a JSON object with the following definition:
4660
```json
4761
{
4862
"response": "AOK",
4963
"error": null
5064
}
5165
```
52-
which can be used as a small healthcheck for these applications.
66+
which can be used as a small healthcheck for apps running `@cisl/express`.
5367

5468
## Configuration
5569
Using this package assumes you have a `cog.json` file with at least the following
5670
in it:
5771
```typescript
5872
{
59-
"port": string | number
73+
"port": number
6074
}
6175
```
76+
77+
## Output
78+
`@cisl/express` will only output a single line when you run the
79+
`listen()` command with the following message `@cisl/express listening on port <PORT>`.
80+
This will be output as a standard `console.log`, or if you have `@cisl/logger` installed,
81+
using `logger.info`. You can silence the output, by sending `{quiet: True}` to the
82+
`express()` method above.

0 commit comments

Comments
 (0)