-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a51e19f
Showing
9 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: develop-release | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
docker-release: | ||
uses: smeup/devops/.github/workflows/docker-release.yaml@main | ||
with: | ||
docker-tag: latest | ||
docker-repository-name: kokos-node-workshop | ||
secrets: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
lib | ||
.vscode | ||
package-lock.json | ||
docs | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Build step | ||
FROM node:18-slim AS builder | ||
|
||
WORKDIR /app | ||
|
||
COPY package*.json /app | ||
|
||
# Install node dependencies and build | ||
RUN npm install | ||
COPY . . | ||
RUN npm run build | ||
|
||
# Run step | ||
FROM node:18-slim AS server | ||
|
||
WORKDIR /home/kokos | ||
|
||
COPY package* ./ | ||
|
||
# Install node dependencies | ||
RUN npm install | ||
COPY --from=builder ./app/lib ./lib | ||
|
||
# create kokos group | ||
RUN addgroup kokos | ||
|
||
RUN useradd -m -s /bin/bash -g kokos kokos | ||
|
||
# set working dir permissions | ||
RUN chown -R kokos:kokos /home/kokos | ||
|
||
# run container as user kokos | ||
USER kokos | ||
|
||
EXPOSE 8011 | ||
CMD ["npm", "run", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Micro Executor Node Workshop | ||
|
||
This application is based on: [Kokos SDK Node](https://docs.smeup.cloud/en/CLS-SU/MURUNT/OPE/MURUNT_03/sdk-node). | ||
|
||
## Development | ||
|
||
```sh | ||
git clone https://github.com/smeup/kokos-me-node-workshop.git | ||
cd kokos-me-node-workshop | ||
npm install | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "test-jsonapi", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"type": "module", | ||
"scripts": { | ||
"clean": "rimraf lib", | ||
"build": "npm run clean && tsc", | ||
"test": "NODE_ENV=test jest", | ||
"dev": "NODE_ENV=development nodemon --watch './**/*.ts' --exec node --experimental-specifier-resolution=node --loader ts-node/esm ./src/index.ts", | ||
"start": "NODE_ENV=production node ./lib/index.js", | ||
"test:win": "SET NODE_ENV=test jest", | ||
"dev:win": "SET NODE_ENV=development&&nodemon --watch . -e ts --exec \"node --experimental-specifier-resolution=node --loader ts-node/esm ./src/index.ts\"", | ||
"start:win": "SET NODE_ENV=production node ./lib/entrypoint/restapi/index.js" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@sme.up/kokos-sdk-node": "^0.2.0-SNAPSHOT", | ||
"axios": "^1.7.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { startServer } from "@sme.up/kokos-sdk-node"; | ||
|
||
startServer("me-node-test"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export interface Address { | ||
street: string; | ||
suite: string; | ||
city: string; | ||
zipcode: string; | ||
geo: Geo; | ||
} | ||
|
||
export interface Geo { | ||
lat: string; | ||
lng: string; | ||
} | ||
|
||
export interface Company { | ||
name: string; | ||
catchPhrase: string; | ||
bs: string; | ||
} | ||
|
||
export interface User { | ||
id: number; | ||
name: string; | ||
username: string; | ||
email: string; | ||
address: Address; | ||
phone: string; | ||
website: string; | ||
company: Company; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { | ||
ExecutionContext, | ||
Fun, | ||
KokosService, | ||
SmeupDataStructureWriter, | ||
User, | ||
} from "@sme.up/kokos-sdk-node"; | ||
|
||
import axios from 'axios'; | ||
|
||
async function fetchUsers() { | ||
try { | ||
const response = await axios.get('https://jsonplaceholder.typicode.com/users'); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Error fetching data from API:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
const JsonPlaceholderService: KokosService = { | ||
methods: { | ||
"GET.TRE": getTree, | ||
}, | ||
}; | ||
|
||
async function getTree( | ||
_fun: Fun, | ||
_context: ExecutionContext, | ||
printer: SmeupDataStructureWriter | ||
) { | ||
|
||
const users: User[] = await fetchUsers(); | ||
|
||
users.forEach(el => { | ||
printer.writeTreeNode({ | ||
children: [], | ||
content: { | ||
tipo: "", | ||
parametro: "", | ||
codice: "", | ||
testo: el.username, | ||
}, | ||
}); | ||
|
||
}); | ||
|
||
|
||
|
||
|
||
} | ||
|
||
export default JsonPlaceholderService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"target": "ESNext", | ||
"outDir": "./lib", | ||
"baseUrl": "./src", | ||
"rootDir": "./src", | ||
"moduleResolution": "node", | ||
"alwaysStrict": true, | ||
"strict": true, | ||
"noImplicitAny": true, | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
"esModuleInterop": true, | ||
"declaration": true, | ||
"sourceMap": true | ||
}, | ||
"include": [ | ||
"src/**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
"lib", | ||
"**/*.test.ts" | ||
] | ||
} |