Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
Conflicts:
	docker-compose.yml
	package.json
  • Loading branch information
startxfr committed Mar 9, 2019
2 parents 88500e1 + d2fefbc commit eeaffe4
Show file tree
Hide file tree
Showing 26 changed files with 131 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env:
- secure: "GJeuDtHqYz70+p0t5MmAA/k50ncT3ao+IxChjfceyAZ3EV5Ij00eanz3Z5cLnWzeoqwOOzDK+lYaRYhySxVtYaRyw0qIqypiPnuTjRykEJ4+bOUZrwYEa9c9TvQgWMvlVDRBiVATRYQ692+WTbIqEifMSQ/tkELws6H9gCE93PEyaAUv8X8ugawdTack+zKxAJgse9WCQ28SM16NqFAL3Rnd/6lHVRefgvcH7XrWnX4xD60HTULWon8MV8pjyp3cSTfQ27SgIiYMaIg8QadsJXJgZpl5h7EWV5p2Qat6sua8ZWCAcpTtwxwvQwAcwkXWxCE9V0HXk05bbNxg4UQlWxMiqo/KZYD9SQDOde7pFLmbFdHNexKnMAhSro87T1ZUw7cUmYlpR8O4LUQtreDc6K1RYApwkZQUtd8Vz197SWXXI+JHzPWgZ+QwkxcBVHofqxQ5hGPulBEsQYcWGNf9Jss9+Af50p8CAPYWH4EHjw6rLivJt0r2xRLdD5tDqOmSrGc8Y/+HSdTMIvQ+8e/7V7hZ6PmA2+0bRM1I3V4OdKTXP/fjxLj/2yyJ0gTvmT1pii9lD7q1hEuFgyuWzBtZRFBPAZt9HidkmkBhhnEBuTrsTKNcebZtXPgFDyV5PLNw1L1bBHvIRvWc2Jn9IrzODOdiz2VT5qzn7FAyulExEak=" # DOCKER_PASS
- COMMIT=${TRAVIS_COMMIT::8}
- REPO=startx/sxapi
- RELEASE=0.3.2
- RELEASE=0.3.3

sudo: required

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM node:8-alpine
MAINTAINER STARTX "dev@startx.fr"

ENV SXAPI_VERSION=0.3.2 \
ENV SXAPI_VERSION=0.3.3 \
SX_ID="startx/sxapi" \
SX_NAME="Startx SXAPI (alpine)" \
SX_SUMMARY="Small an eXtensible API framework to build small and flexible microservices using a single configuration file" \
Expand Down
2 changes: 1 addition & 1 deletion ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If the current behavior is a bug, please provide the steps to reproduce and if p

* **Please tell us about your environment:**

- version: 0.3.2 (npm, docker)
- version: 0.3.3 (npm, docker)
- Browser: "Firefox 21.0.2"
- Nodejs: "NodeJS 2.1.2"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![sxapi](https://raw.githubusercontent.com/startxfr/sxapi-core/master/docs/assets/logo.svg?sanitize=true)](https://github.com/startxfr/sxapi-core)

# sxapi-core project ![sxapi](https://img.shields.io/badge/latest-v0.3.2-blue.svg)
# sxapi-core project ![sxapi](https://img.shields.io/badge/latest-v0.3.3-blue.svg)

**sxapi** for **s**imple and e**x**tensible **api** (Application Programming Interface) is an an open-source framework for quickly building simple and small API based on microservice architecture.

Expand Down
4 changes: 2 additions & 2 deletions bot-sxapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ log:
level: '0,1,2,3,4'
type: debug,info,error,warn
server:
port: '8080'
port: '8077'
endpoints:
- path: "/"
desc: Display welcome message (HTML)
body: "<html><head><title>sxapi-core API</title></head><body><h1>Your API is live
!</h1><p>This API is based on sxapi-core v0.3.2 and use default config file.
!</h1><p>This API is based on sxapi-core v0.3.3 and use default config file.
You can now start to configure your sxapi.yml config file in order to build
your own API </p></body></html>"
- path: "/health"
Expand Down
2 changes: 1 addition & 1 deletion core/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $app = {
notification: null,
// application package configuration
package: {
network_port: "8080"
network_port: "8077"
},
// application configuration
config: {
Expand Down
4 changes: 2 additions & 2 deletions core/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var $ws = {
throw new Error("no 'server' section in config");
}
if (!$ws.config.port) {
$ws.config.port = "8080";
$ws.config.port = "8077";
}
if ($ws.config.port) {
$ws.config.port = $log.format($ws.config.port, process.env);
Expand Down Expand Up @@ -256,7 +256,7 @@ var $ws = {
if ($ws.config.enableWebsockets === true) {
this.websockets.start();
}
$ws.server.listen($ws.config.port || 8080);
$ws.server.listen($ws.config.port || 8077);
}
catch (err) {
$log.error('web server can\'t start because ' + err.message);
Expand Down
33 changes: 15 additions & 18 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,31 @@ app:
build: .
container_name: "sxapi-core-master"
ports:
- "8080:8080"
- "8077:8077"
volumes:
- "./sxapi.yml:/conf/sxapi.yml:z"
- "./test:/test:z"
working_dir: /usr/src/app
## build application
# command: ["npm" , "run" , "build"]
## run application
# command: ["npm" , "start"]
## build and start application for dev environement
## build, test and start application for dev environement (with live-reload when code change)
# command: ["npm" , "run", "dev"]
## install application for dev environement
# command: ["npm", "run", "dev:install"]
## update application depndencies
# command: ["npm" , "run" , "dev:update"]
## build application for dev environement
## build application for dev environement (clean, install and update)
# command: ["npm" , "run" , "dev:build"]
## start application for dev environement
command: ["npm" , "run" , "dev:start"]
## run application test
## start application for dev environement (install, test and start application)
# command: ["npm" , "run" , "dev:start"]

## run application test only
# command: ["npm" , "test"]
## build application for testing
# command: ["npm" , "run" , "test:build"]
## start application for testing
# command: ["npm" , "run" , "test:start"]
## build application for production

## build application for production (clean, install and update)
# command: ["npm" , "run" , "prod:build"]
## start application for production
# command: ["npm" , "run" , "prod:start"]
## build and start application for production
## build, test and start application for production
# command: ["npm" , "run" , "prod"]

## build application for production (alias `npm run prod:build`)
command: ["npm" , "run" , "build"]
## run application (node app.js)
# command: ["npm" , "start"]
4 changes: 2 additions & 2 deletions docs/core/ws.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ connections.

| Param | Mandatory | Type | default | Description
|---------------------------------|:---------:|:-------:|---------|---------------
| **port** | no | int | 8080 | Webserver port
| **port** | no | int | 8077 | Webserver port
| **enableWebsockets** | no | bool | false | Enable socket.io connection
| **websockets** | no | obj | | socket.io configuration
| websockets.**onConnection** | no | string | | Function to use when a new client connect (leave blank for autoLoading events)
Expand Down Expand Up @@ -72,7 +72,7 @@ connections.

```yaml
server:
port: '8080'
port: '8077'
endpoints:
- path: "/ping"
desc: Ping the application. Return a sample message in json
Expand Down
56 changes: 47 additions & 9 deletions docs/guides/2.Configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,67 @@

# SXAPI configuration user guide

You have 3 ways to configure an sxapi instance.
- With a configuration file (sxapi.yml)
- With a configuration environement ($SXAPI_CONF)

Configuration loading sequence
------------------------------

## Configuration file (sxapi.yml)

You can create a `sxapi.yml` file located on the path defined by the environment `$APP_PATH`.
Your configuration file must be a valid sxapi configuration file like,
[sxapi configuration example](#sxapi-description-example)


sxapi.yml structure
--------------------
## Configuration environement (SXAPI_CONF)

You can create an environment variable named `SXAPI_CONF` in you application platefrom.
Your environement variable should be a valid sxapi configuration file, like
[sxapi configuration example](#sxapi-description-example)


## Sxapi description example


### Static homepage example

This is a simple sxapi description for a single static webpage

```yaml
name: sample-api
description: my sample api using sxapi-core framework
description: sample api using sxapi-core framework for a single homepage
version: 0.0.0
debug: true
log:
filters:
level: '0,1,2,3,4'
type: debug,info,error,warn
resources:
serviceinfo-id:
_class: serviceinfo
server:
endpoints:
- path: "/"
body: "<html><head></head><body><h1>My API</h1></body></html>"
```

### Application information example

This is a simple sxapi description for dynamic information about the running application.

```yaml
name: sample-api
description: my sample api using sxapi-core framework for dynamic information about the running application.
version: 0.0.0
debug: true
resources:
serviceinfo-id:
_class: serviceinfo
server:
endpoints:
- path: "/"
resource: serviceinfo-id
endpoint: info
- path: "/health"
resource: serviceinfo-id
endpoint: health
- path: "/env"
resource: serviceinfo-id
endpoint: getEnv
```
2 changes: 1 addition & 1 deletion docs/guides/3.Run.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ test service
------------

```bash
wget http://localhost:8080/
wget http://localhost:8077/
```

Monitor service
Expand Down
20 changes: 10 additions & 10 deletions docs/guides/USE_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ You can change `name`, `description`, `version` and `server.endpoints.body` with
with your own configuration file

```bash
docker run -d -p 8080:8080 -v ~/test-sxapi/sxapi.yml:/conf/sxapi.yml:ro startx/sxapi
docker run -d -p 8077:8077 -v ~/test-sxapi/sxapi.yml:/conf/sxapi.yml:ro startx/sxapi
```

or using environement variable

```bash
docker run -d -p 8080:8080 --env SXAPI_CONF=$(cat ~/test-sxapi/sxapi.yml) startx/sxapi
docker run -d -p 8077:8077 --env SXAPI_CONF=$(cat ~/test-sxapi/sxapi.yml) startx/sxapi
```

### 6. Explore your api

Connect to `http://localhost:8080/` with your favorite navigator. You should
Connect to `http://localhost:8077/` with your favorite navigator. You should
see an html message "My Sample API".


Expand All @@ -104,13 +104,13 @@ docker pull startx/sxapi:latest

2. Run your sample application
```bash
// run on port 8080 and attach console
// run on port 8077 and attach console
docker run startx/sxapi
// or run in detached mode and expose port 81
docker run -d -p 81:8080 startx/sxapi
docker run -d -p 81:8077 startx/sxapi
```

3. Connect to `http://localhost:8080` or `http://localhost:81`
3. Connect to `http://localhost:8077` or `http://localhost:81`
with your favorite navigator


Expand Down Expand Up @@ -142,10 +142,10 @@ server:

3. Run your application
```bash
docker run -d -p 8080:8080 -v $(pwd)/sxapi.yml:/conf/sxapi.yml:ro startx/sxapi
docker run -d -p 8077:8077 -v $(pwd)/sxapi.yml:/conf/sxapi.yml:ro startx/sxapi
```

4. Connect to `http://localhost:8080` with your favorite navigator
4. Connect to `http://localhost:8077` with your favorite navigator


### Container with your own configuration (docker-compose)
Expand All @@ -157,7 +157,7 @@ api:
image: startx/sxapi:latest
container_name: "my-api"
ports:
- "8080:8080"
- "8077:8077"
volumes:
- "./sxapi-dev.yml:/conf/sxapi.yml:ro"
```
Expand Down Expand Up @@ -185,7 +185,7 @@ server:
docker-compose up
```

4. Connect to `http://localhost:8080` with your favorite navigator
4. Connect to `http://localhost:8077` with your favorite navigator


### Using Openshift
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/USE_npm.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sxapi.app.launch(function () {
node app.js
```

4. Connect to `http://localhost:8080` with your favorite navigator
4. Connect to `http://localhost:8077` with your favorite navigator



Expand Down Expand Up @@ -69,6 +69,6 @@ server:
node app.js
```

4. Connect to `http://localhost:8080` with your favorite navigator
4. Connect to `http://localhost:8077` with your favorite navigator


4 changes: 2 additions & 2 deletions docs/guides/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
app:
image: node:8
image: node:10-alpine
container_name: "sxapi-core-dev"
ports:
- "8080:8080"
- "8077:8077"
environment:
- NODE_ENV=development
- APP_PATH=/usr/src/app
Expand Down
12 changes: 6 additions & 6 deletions docs/guides/openshift-template-configMap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ objects:
spec:
clusterIP: None
ports:
- name: app
port: 8080
- name: sxapi
port: 8077
selector:
name: "${APPLICATION_NAME}"
type: application
Expand Down Expand Up @@ -52,7 +52,7 @@ objects:
livenessProbe:
initialDelaySeconds: 20
tcpSocket:
port: 8080
port: 8077
timeoutSeconds: 2
lifecycle:
preStop:
Expand All @@ -61,8 +61,8 @@ objects:
- "npm"
- stop
ports:
- containerPort: 8080
name: app
- name: sxapi
containerPort: 8077
resources:
requests:
memory: "${MEMORY_LIMIT}"
Expand All @@ -86,7 +86,7 @@ parameters:
value: sxapi-demo
required: true
- name: IMAGE_NAME
value: 0.3.2
value: 0.3.3
required: true
- name: REGISTRY
value: "startx/sxapi"
Expand Down

0 comments on commit eeaffe4

Please sign in to comment.