-
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
1 parent
984b50c
commit 73af1fc
Showing
14 changed files
with
263 additions
and
58 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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
DATABASE_URL=sqlite://./db.sqlite | ||
PLT_SERVER_HOSTNAME=127.0.0.1 | ||
PORT=3042 | ||
PORT=3001 | ||
PLT_SERVER_LOGGER_LEVEL=info | ||
DATABASE_URL=sqlite://./db.sqlite | ||
MAIL_USER=[email protected] | ||
MAIL_PASS=emailpassword | ||
MAIL_SERVICE=SMTP_email_service | ||
TUTOR_MAIL=[email protected] | ||
PLT_ACCESS_TOKEN=<hex_token> | ||
|
||
|
59 changes: 59 additions & 0 deletions
59
.github/workflows/platformatic-dynamic-workspace-deploy.yml
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,59 @@ | ||
name: Deploy Platformatic application to the cloud | ||
on: | ||
pull_request: | ||
paths-ignore: | ||
- 'docs/**' | ||
- '**.md' | ||
workflow_dispatch: | ||
inputs: | ||
label: | ||
description: "Preview Label" | ||
required: true | ||
default: "" | ||
|
||
jobs: | ||
build_and_deploy: | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
DATABASE_URL: ${{ secrets.DATABASE_URL }} | ||
PLT_SERVER_LOGGER_LEVEL: info | ||
PORT: 3001 | ||
PLT_SERVER_HOSTNAME: 127.0.0.1 | ||
DEPLOY_SERVICE_HOST: https://deploy.platformatic.cloud | ||
|
||
|
||
steps: | ||
- name: Checkout application project repository | ||
uses: actions/checkout@v3 | ||
- name: npm install --omit=dev | ||
run: npm install --omit=dev | ||
- name: Deploy project | ||
id: deploy-project | ||
uses: platformatic/onestep@latest | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
platformatic_workspace_id: ${{ secrets.PLATFORMATIC_DYNAMIC_WORKSPACE_ID }} | ||
platformatic_workspace_key: ${{ secrets.PLATFORMATIC_DYNAMIC_WORKSPACE_API_KEY }} | ||
platformatic_config_path: ./platformatic.db.json | ||
label: ${{ github.event.inputs.label }} | ||
outputs: | ||
deployment_id: ${{ steps.deploy-project.outputs.deployment_id }} | ||
calculate_risk: | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
needs: build_and_deploy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Calculate risk | ||
uses: platformatic/onestep/actions/calculate-risk@latest | ||
if: github.event_name == 'pull_request' | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
platformatic_workspace_id: ${{ secrets.PLATFORMATIC_DYNAMIC_WORKSPACE_ID }} | ||
platformatic_workspace_key: ${{ secrets.PLATFORMATIC_DYNAMIC_WORKSPACE_API_KEY }} | ||
platformatic_deployment_id: ${{ needs.build_and_deploy.outputs.deployment_id }} |
37 changes: 37 additions & 0 deletions
37
.github/workflows/platformatic-static-workspace-deploy.yml
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,37 @@ | ||
name: Deploy Platformatic application to the cloud | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- 'docs/**' | ||
- '**.md' | ||
workflow_dispatch: | ||
inputs: | ||
|
||
jobs: | ||
build_and_deploy: | ||
permissions: | ||
contents: read | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
DATABASE_URL: ${{ secrets.DATABASE_URL }} | ||
PLT_SERVER_LOGGER_LEVEL: info | ||
PORT: 3001 | ||
PLT_SERVER_HOSTNAME: 127.0.0.1 | ||
DEPLOY_SERVICE_HOST: https://deploy.platformatic.cloud | ||
|
||
|
||
steps: | ||
- name: Checkout application project repository | ||
uses: actions/checkout@v3 | ||
- name: npm install --omit=dev | ||
run: npm install --omit=dev | ||
- name: Deploy project | ||
uses: platformatic/onestep@latest | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
platformatic_workspace_id: ${{ secrets.PLATFORMATIC_STATIC_WORKSPACE_ID }} | ||
platformatic_workspace_key: ${{ secrets.PLATFORMATIC_STATIC_WORKSPACE_API_KEY }} | ||
platformatic_config_path: ./platformatic.db.json |
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 |
---|---|---|
|
@@ -25,5 +25,3 @@ tags | |
|
||
# clinicjs | ||
.clinic/ | ||
|
||
seq.drawio |
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 |
---|---|---|
@@ -1,14 +1,6 @@ | ||
CREATE TABLE IF NOT EXISTS users ( | ||
|
||
-- Add SQL in this file to create the database tables for your API | ||
CREATE TABLE IF NOT EXISTS movies ( | ||
id INTEGER PRIMARY KEY, | ||
first_name TEXT NOT NULL, | ||
last_name TEXT NOT NULL, | ||
email TEXT NOT NULL UNIQUE, | ||
password TEXT NOT NULL, | ||
mobile_no INTEGER NOT NULL UNIQUE, | ||
is_email_verified INTEGER CHECK( is_email_verified IN (0, 1) ) NOT NULL DEFAULT 0, | ||
is_mobile_verified INTEGER CHECK( is_mobile_verified IN (0, 1) ) NOT NULL DEFAULT 0, | ||
_type TEXT CHECK( _type IN ('student', 'tutor') ) NOT NULL, | ||
_status INTEGER CHECK( _status IN (0, 1) ) NOT NULL DEFAULT 1, | ||
_created_on DATETIME NOT NULL, | ||
_modified_on DATETIME NOT NULL | ||
title TEXT NOT NULL | ||
); |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
DROP TABLE users; | ||
|
||
-- Add SQL in this file to drop the database tables | ||
DROP TABLE movies; |
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 |
---|---|---|
@@ -1,24 +1,15 @@ | ||
{ | ||
"scripts": { | ||
"start": "platformatic start", | ||
"migrate": "platformatic db migrations apply" | ||
"test": "node --test test/**" | ||
}, | ||
"devDependencies": { | ||
"fastify": "^4.21.0" | ||
"fastify": "^4.24.3" | ||
}, | ||
"dependencies": { | ||
"@platformatic/db": "^0.38.1", | ||
"@platformatic/sql-graphql": "^0.38.1", | ||
"@platformatic/sql-mapper": "^0.38.1", | ||
"bcrypt": "^5.1.1", | ||
"dotenv": "^16.3.1", | ||
"handlebars": "^4.7.8", | ||
"jsonwebtoken": "^9.0.2", | ||
"moment": "^2.29.4", | ||
"nodemailer": "^6.9.7", | ||
"platformatic": "^0.38.1" | ||
"platformatic": "^1.10.0" | ||
}, | ||
"engines": { | ||
"node": "^18.8.0" | ||
"node": "^18.8.0 || >=20.6.0" | ||
} | ||
} | ||
} |
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
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 @@ | ||
/// <reference path="../global.d.ts" /> | ||
'use strict' | ||
/** @param {import('fastify').FastifyInstance} fastify */ | ||
module.exports = async function (fastify, opts) { | ||
fastify.decorate('example', 'foobar') | ||
} |
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,8 @@ | ||
/// <reference path="../global.d.ts" /> | ||
'use strict' | ||
/** @param {import('fastify').FastifyInstance} fastify */ | ||
module.exports = async function (fastify, opts) { | ||
fastify.get('/example', async (request, reply) => { | ||
return { hello: fastify.example } | ||
}) | ||
} |
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,40 @@ | ||
'use strict' | ||
|
||
const { join } = require('node:path') | ||
const { readFile } = require('node:fs/promises') | ||
const { buildServer } = require('@platformatic/db') | ||
|
||
const os = require('node:os') | ||
const path = require('node:path') | ||
const fs = require('node:fs/promises') | ||
|
||
let counter = 0 | ||
|
||
|
||
async function getServer (t) { | ||
|
||
const dbPath = join(os.tmpdir(), 'db-' + process.pid + '-' + counter++ + '.sqlite') | ||
const connectionString = 'sqlite://' + dbPath | ||
|
||
const config = JSON.parse(await readFile(join(__dirname, '..', 'platformatic.db.json'), 'utf8')) | ||
// Add your config customizations here. For example you want to set | ||
// all things that are set in the config file to read from an env variable | ||
config.server.logger.level = 'warn' | ||
config.watch = false | ||
|
||
config.migrations.autoApply = true | ||
config.types.autogenerate = false | ||
config.db.connectionString = connectionString | ||
|
||
// Add your config customizations here | ||
const server = await buildServer(config) | ||
t.after(() => server.close()) | ||
|
||
t.after(async () => { | ||
await fs.unlink(dbPath) | ||
}) | ||
|
||
return server | ||
} | ||
|
||
module.exports.getServer = getServer |
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 @@ | ||
'use strict' | ||
|
||
const test = require('node:test') | ||
const assert = require('node:assert') | ||
const { getServer } = require('../helper') | ||
|
||
test('example decorator', async (t) => { | ||
const server = await getServer(t) | ||
|
||
assert.strictEqual(server.example, 'foobar') | ||
}) |
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,49 @@ | ||
'use strict' | ||
|
||
const test = require('node:test') | ||
const assert = require('node:assert') | ||
const { getServer } = require('../helper') | ||
|
||
test('movies', async (t) => { | ||
const server = await getServer(t) | ||
|
||
{ | ||
const res = await server.inject({ | ||
method: 'GET', | ||
url: '/movies' | ||
}) | ||
|
||
assert.strictEqual(res.statusCode, 200) | ||
assert.deepStrictEqual(res.json(), []) | ||
} | ||
|
||
let id | ||
{ | ||
const res = await server.inject({ | ||
method: 'POST', | ||
url: '/movies', | ||
body: { | ||
title: 'The Matrix' | ||
} | ||
}) | ||
|
||
assert.strictEqual(res.statusCode, 200) | ||
const body = res.json() | ||
assert.strictEqual(body.title, 'The Matrix') | ||
assert.strictEqual(body.id !== undefined, true) | ||
id = body.id | ||
} | ||
|
||
{ | ||
const res = await server.inject({ | ||
method: 'GET', | ||
url: '/movies' | ||
}) | ||
|
||
assert.strictEqual(res.statusCode, 200) | ||
assert.deepStrictEqual(res.json(), [{ | ||
id, | ||
title: 'The Matrix' | ||
}]) | ||
} | ||
}) |
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,18 @@ | ||
'use strict' | ||
|
||
const test = require('node:test') | ||
const assert = require('node:assert') | ||
const { getServer } = require('../helper') | ||
|
||
test('example', async (t) => { | ||
const server = await getServer(t) | ||
const res = await server.inject({ | ||
method: 'GET', | ||
url: '/example' | ||
}) | ||
|
||
assert.strictEqual(res.statusCode, 200) | ||
assert.deepStrictEqual(res.json(), { | ||
hello: 'foobar' | ||
}) | ||
}) |