Compare commits
90 Commits
main
...
feature/sl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d95bceadca | ||
|
|
9f9f9da1f1 | ||
|
|
a799f7fb11 | ||
|
|
6ff55ff2bb | ||
|
|
ada7785b64 | ||
|
|
20f1fa8632 | ||
|
|
7789c8499e | ||
|
|
dd96cbb1d3 | ||
|
|
acb321250f | ||
|
|
9bbe50c98c | ||
|
|
4caaefdfbc | ||
|
|
8327a60086 | ||
|
|
eb0f2f1cdb | ||
|
|
0c2e1076e9 | ||
|
|
e9ba654b25 | ||
|
|
1728e1de36 | ||
|
|
73ef6573fc | ||
|
|
e8ae0d6e2f | ||
|
|
22397bddc2 | ||
|
|
cdaa90f241 | ||
|
|
37a1b6fe8d | ||
|
|
5a99176d84 | ||
|
|
1298d63ace | ||
|
|
137fd7cc52 | ||
|
|
c6d9051aa0 | ||
|
|
ddbb39acb8 | ||
|
|
11bee016d2 | ||
|
|
9f4dbdb402 | ||
|
|
c820e1de8f | ||
|
|
24e3ec9e39 | ||
|
|
a55c404484 | ||
|
|
22be8a5024 | ||
|
|
5ceb5f1fa2 | ||
|
|
3b927809a8 | ||
|
|
302d370955 | ||
|
|
338caa75d1 | ||
|
|
57a40eae33 | ||
|
|
1ffb8e4193 | ||
|
|
33c954fff1 | ||
|
|
6bd3626047 | ||
|
|
a502c5dcb7 | ||
|
|
ba78011d49 | ||
|
|
e28c18765c | ||
|
|
92ffa5e035 | ||
|
|
2e7342c3e6 | ||
|
|
95c046bdf3 | ||
|
|
cae0a6de93 | ||
|
|
3756619aaf | ||
|
|
c02773b5cf | ||
|
|
e3aa781d9a | ||
|
|
76a7484bdb | ||
|
|
d71d91daee | ||
|
|
95b5836724 | ||
|
|
078ff9c6b2 | ||
|
|
568ce6a4e0 | ||
|
|
51bc7f4bfd | ||
|
|
aeb3281cff | ||
|
|
4f8c8a714f | ||
|
|
54bd731f86 | ||
|
|
c83992363a | ||
|
|
4c6f41c679 | ||
|
|
91069008a6 | ||
|
|
59757ae8ae | ||
|
|
558835bc28 | ||
|
|
aacde35239 | ||
|
|
1524fa196e | ||
|
|
6515fba1bc | ||
|
|
08231dc261 | ||
|
|
d5ca45110e | ||
|
|
763916a437 | ||
|
|
f7887f9418 | ||
|
|
290aee542a | ||
|
|
02480498b5 | ||
|
|
3307797e00 | ||
|
|
30bb049277 | ||
|
|
754a145587 | ||
|
|
6d1460d360 | ||
|
|
a523e85a18 | ||
|
|
dd188d55a2 | ||
|
|
6fc53ffe97 | ||
|
|
9979d496e4 | ||
|
|
4a33665a5b | ||
|
|
50309ce680 | ||
|
|
7a9d58d78a | ||
|
|
a1aab81eb5 | ||
|
|
0ffa190250 | ||
|
|
64d6b877e1 | ||
|
|
897901dffd | ||
|
|
e18c122c2b | ||
|
|
03ff94aa5a |
118
.gitignore
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
.env.production
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
12
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch server-side",
|
||||
"type": "node-terminal",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceFolder}/packages/backend",
|
||||
"command": "yarn dev"
|
||||
}
|
||||
]
|
||||
}
|
||||
5
CONTRIBUTOR_LICENSE_AGREEMENT.md
Normal file
@ -0,0 +1,5 @@
|
||||
# automatisch Contributor License Agreement
|
||||
|
||||
I give automatisch permission to license my contributions on any terms they like. I am giving them this license in order to make it possible for them to accept my contributions into their project.
|
||||
|
||||
***As far as the law allows, my contributions come as is, without any warranty or condition, and I will not be liable to anyone for any damages related to this software or this license, under any kind of legal claim.***
|
||||
230
LICENSE.md
Normal file
@ -0,0 +1,230 @@
|
||||
“Commons Clause” License Condition v1.0
|
||||
|
||||
The Software is provided to you by the Licensor under the
|
||||
License, as defined below, subject to the following condition.
|
||||
|
||||
Without limiting other conditions in the License, the grant
|
||||
of rights under the License will not include, and the License
|
||||
does not grant to you, the right to Sell the Software.
|
||||
|
||||
For purposes of the foregoing, “Sell” means practicing any or
|
||||
all of the rights granted to you under the License to provide
|
||||
to third parties, for a fee or other consideration (including
|
||||
without limitation fees for hosting or consulting/ support
|
||||
services related to the Software), a product or service whose
|
||||
value derives, entirely or substantially, from the functionality
|
||||
of the Software. Any license notice or attribution required by
|
||||
the License must also include this Commons Clause License
|
||||
Condition notice.
|
||||
|
||||
Software: automatisch
|
||||
|
||||
License: Apache 2.0 with Commons Clause
|
||||
|
||||
Licensor: Ali Barın, Ömer Faruk Aydın
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2021 Ali Barın, Ömer Faruk Aydın
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@ -9,6 +9,9 @@
|
||||
"command": {
|
||||
"publish": {
|
||||
"registry": "http://localhost:5000"
|
||||
},
|
||||
"add": {
|
||||
"exact": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
{
|
||||
"name": "@automatisch/root",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "lerna run --stream --scope=@*/{web,backend} dev",
|
||||
"start:web": "lerna run --stream --scope @*/web dev",
|
||||
"start:backend": "lerna run --stream --scope @*/backend dev"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
|
||||
11
packages/backend/.env-example
Normal file
@ -0,0 +1,11 @@
|
||||
HOST=localhost
|
||||
PROTOCOL=http
|
||||
PORT=3000
|
||||
CORS_PORT=3001
|
||||
CORS_PROTOCOL=https
|
||||
APP_ENV=development
|
||||
POSTGRES_DATABASE=automatisch_development
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_HOST=localhost
|
||||
POSTGRES_USERNAME=automatish_development_user
|
||||
POSTGRESS_PASSWORD=
|
||||
11
packages/backend/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# `backend`
|
||||
|
||||
> TODO: description
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
const backend = require('backend');
|
||||
|
||||
// TODO: DEMONSTRATE API
|
||||
```
|
||||
9
packages/backend/bin/database/client.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Client } from 'pg';
|
||||
|
||||
const client = new Client({
|
||||
host: 'localhost',
|
||||
user: 'postgres',
|
||||
port: 5432,
|
||||
})
|
||||
|
||||
export default client;
|
||||
15
packages/backend/bin/database/create-user.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import User from '../../src/models/user';
|
||||
import '../../src/config/database';
|
||||
import logger from '../../src/helpers/logger';
|
||||
|
||||
const userParams = {
|
||||
email: 'user@automatisch.com',
|
||||
password: 'sample',
|
||||
};
|
||||
|
||||
async function createUser() {
|
||||
const user = await User.query().insertAndFetch(userParams);
|
||||
logger.info(`User has been saved: ${user.email}`);
|
||||
}
|
||||
|
||||
createUser();
|
||||
42
packages/backend/bin/database/create.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import appConfig from '../../src/config/app';
|
||||
import logger from '../../src/helpers/logger';
|
||||
import client from './client';
|
||||
|
||||
const createDatabaseAndUser = async () => {
|
||||
if(appConfig.appEnv !== 'development' && appConfig.appEnv !== 'test') {
|
||||
const errorMessage = 'Database creation can be used only with development or test environments!'
|
||||
logger.error(errorMessage)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await client.connect();
|
||||
await createDatabase();
|
||||
await createDatabaseUser();
|
||||
await grantPrivileges();
|
||||
|
||||
await client.end();
|
||||
}
|
||||
|
||||
const createDatabase = async () => {
|
||||
await client.query(`CREATE DATABASE ${appConfig.postgresDatabase}`);
|
||||
logger.info(`Database: ${appConfig.postgresDatabase} created!`);
|
||||
}
|
||||
|
||||
const createDatabaseUser = async () => {
|
||||
await client.query(`CREATE USER ${appConfig.postgresUsername}`);
|
||||
logger.info(`Database User: ${appConfig.postgresUsername} created!`);
|
||||
}
|
||||
|
||||
const grantPrivileges = async () => {
|
||||
await client.query(
|
||||
`GRANT ALL PRIVILEGES ON DATABASE ${appConfig.postgresDatabase} TO ${appConfig.postgresUsername};`
|
||||
);
|
||||
|
||||
logger.info(
|
||||
`${appConfig.postgresUsername} has granted all privileges on ${appConfig.postgresDatabase}!`
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
createDatabaseAndUser();
|
||||
29
packages/backend/bin/database/drop.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import appConfig from '../../src/config/app';
|
||||
import logger from '../../src/helpers/logger';
|
||||
import client from './client';
|
||||
|
||||
const dropDatabase = async () => {
|
||||
if (appConfig.appEnv != 'development' && appConfig.appEnv != 'test') {
|
||||
const errorMessage = 'Drop database command can be used only with development or test environments!'
|
||||
|
||||
logger.error(errorMessage)
|
||||
return;
|
||||
}
|
||||
|
||||
await client.connect();
|
||||
await dropDatabaseAndUser();
|
||||
|
||||
await client.end();
|
||||
}
|
||||
|
||||
const dropDatabaseAndUser = async() => {
|
||||
await client.query(`DROP DATABASE IF EXISTS ${appConfig.postgresDatabase}`);
|
||||
logger.info(`Database: ${appConfig.postgresDatabase} removed!`);
|
||||
|
||||
await client.query(`DROP USER IF EXISTS ${appConfig.postgresUsername}`);
|
||||
logger.info(`Database User: ${appConfig.postgresUsername} removed!`);
|
||||
}
|
||||
|
||||
|
||||
|
||||
dropDatabase();
|
||||
20
packages/backend/knexfile.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import appConfig from './src/config/app';
|
||||
|
||||
const knexConfig = {
|
||||
client: 'pg',
|
||||
connection: {
|
||||
host: appConfig.postgresHost,
|
||||
port: appConfig.postgresPort,
|
||||
user: appConfig.postgresUsername,
|
||||
password: appConfig.postgresPassword,
|
||||
database: appConfig.postgresDatabase,
|
||||
},
|
||||
migrations: {
|
||||
directory: __dirname + '/src/db/migrations',
|
||||
},
|
||||
seeds: {
|
||||
directory: __dirname + '/src/db/seeds',
|
||||
}
|
||||
}
|
||||
|
||||
export default knexConfig;
|
||||
89
packages/backend/package.json
Normal file
@ -0,0 +1,89 @@
|
||||
{
|
||||
"name": "@automatisch/backend",
|
||||
"version": "0.1.0",
|
||||
"description": "> TODO: description",
|
||||
"scripts": {
|
||||
"dev": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/app.ts",
|
||||
"build": "tsc",
|
||||
"start": "node dist/index.js",
|
||||
"test": "ava",
|
||||
"db:create": "ts-node ./bin/database/create.ts",
|
||||
"db:create:user": "ts-node ./bin/database/create-user.ts",
|
||||
"db:drop": "ts-node ./bin/database/drop.ts",
|
||||
"db:migration:create": "knex migrate:make",
|
||||
"db:rollback": "knex migrate:rollback",
|
||||
"db:migrate": "knex migrate:latest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@octokit/oauth-methods": "^1.2.6",
|
||||
"@slack/oauth": "2.3.0",
|
||||
"axios": "0.24.0",
|
||||
"bcrypt": "^5.0.1",
|
||||
"cors": "^2.8.5",
|
||||
"debug": "~2.6.9",
|
||||
"discord.js": "13.2.0",
|
||||
"dotenv": "^10.0.0",
|
||||
"express": "~4.16.1",
|
||||
"express-graphql": "^0.12.0",
|
||||
"flickr-sdk": "3.10.0",
|
||||
"googleapis": "89.0.0",
|
||||
"graphql-type-json": "^0.3.2",
|
||||
"http-errors": "~1.6.3",
|
||||
"knex": "^0.95.11",
|
||||
"morgan": "^1.10.0",
|
||||
"nodemailer": "6.7.0",
|
||||
"objection": "^2.2.17",
|
||||
"pg": "^8.7.1",
|
||||
"twilio": "3.70.0",
|
||||
"twitch-js": "2.0.0-beta.42",
|
||||
"twitter-api-v2": "1.6.0",
|
||||
"winston": "^3.3.3"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "automatisch contributors",
|
||||
"url": "https://github.com/automatisch/automatisch/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"homepage": "https://github.com/automatisch/automatisch#readme",
|
||||
"main": "src/app.ts",
|
||||
"directories": {
|
||||
"src": "src",
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/automatisch/automatisch.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/automatisch/automatisch/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bcrypt": "^5.0.0",
|
||||
"@types/cors": "^2.8.12",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/http-errors": "^1.8.1",
|
||||
"@types/morgan": "^1.9.3",
|
||||
"@types/node": "^16.10.2",
|
||||
"@types/nodemailer": "^6.4.4",
|
||||
"@types/pg": "^8.6.1",
|
||||
"ava": "^3.15.0",
|
||||
"nodemon": "^2.0.13",
|
||||
"sinon": "^11.1.2",
|
||||
"ts-node": "^10.2.1"
|
||||
},
|
||||
"ava": {
|
||||
"files": [
|
||||
"test/**/*"
|
||||
],
|
||||
"extensions": [
|
||||
"ts"
|
||||
],
|
||||
"require": [
|
||||
"ts-node/register"
|
||||
]
|
||||
}
|
||||
}
|
||||
36
packages/backend/src/app.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import appConfig from './config/app'
|
||||
import createError from 'http-errors';
|
||||
import express, { Request, Response, NextFunction } from 'express';
|
||||
import cors from 'cors';
|
||||
import corsOptions from './config/cors-options';
|
||||
import graphQLInstance from './helpers/graphql-instance';
|
||||
import logger from './helpers/logger';
|
||||
import morgan from './helpers/morgan';
|
||||
import appAssetsHandler from './helpers/app-assets-handler';
|
||||
import errorHandler from './helpers/error-handler';
|
||||
import './config/database';
|
||||
import './helpers/eager-load-apps';
|
||||
import authentication from './helpers/authentication';
|
||||
|
||||
const app = express();
|
||||
const port = appConfig.port;
|
||||
|
||||
appAssetsHandler(app)
|
||||
|
||||
app.use(morgan);
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: false }));
|
||||
app.use(cors(corsOptions));
|
||||
app.use(authentication);
|
||||
app.use('/graphql', graphQLInstance);
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
app.use(function(req: Request, res: Response, next: NextFunction) {
|
||||
next(createError(404));
|
||||
});
|
||||
|
||||
app.use(errorHandler);
|
||||
|
||||
app.listen(port, () => {
|
||||
logger.info(`Server is listening on ${port}`)
|
||||
})
|
||||
4
packages/backend/src/apps/discord/assets/favicon.svg
Normal file
@ -0,0 +1,4 @@
|
||||
<svg fill="#5865f2" aria-label="Discord" role="img" version="1.1" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="512" height="512" rx="15%" fill="#fff"/>
|
||||
<path d="m386 137c-24-11-49.5-19-76.3-23.7c-.5 0-1 0-1.2.6c-3.3 5.9-7 13.5-9.5 19.5c-29-4.3-57.5-4.3-85.7 0c-2.6-6.2-6.3-13.7-10-19.5c-.3-.4-.7-.7-1.2-.6c-23 4.6-52.4 13-76 23.7c-.2 0-.4.2-.5.4c-49 73-62 143-55 213c0 .3.2.7.5 1c32 23.6 63 38 93.6 47.3c.5 0 1 0 1.3-.4c7.2-9.8 13.6-20.2 19.2-31.2c.3-.6 0-1.4-.7-1.6c-10-4-20-8.6-29.3-14c-.7-.4-.8-1.5 0-2c2-1.5 4-3 5.8-4.5c.3-.3.8-.3 1.2-.2c61.4 28 128 28 188 0c.4-.2.9-.1 1.2.1c1.9 1.6 3.8 3.1 5.8 4.6c.7.5.6 1.6 0 2c-9.3 5.5-19 10-29.3 14c-.7.3-1 1-.6 1.7c5.6 11 12.1 21.3 19 31c.3.4.8.6 1.3.4c30.6-9.5 61.7-23.8 93.8-47.3c.3-.2.5-.5.5-1c7.8-80.9-13.1-151-55.4-213c0-.2-.3-.4-.5-.4Zm-192 171c-19 0-34-17-34-38c0-21 15-38 34-38c19 0 34 17 34 38c0 21-15 38-34 38zm125 0c-19 0-34-17-34-38c0-21 15-38 34-38c19 0 34 17 34 38c0 21-15 38-34 38z" fill="#5865f2"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 993 B |
91
packages/backend/src/apps/discord/index.ts
Normal file
@ -0,0 +1,91 @@
|
||||
import { URLSearchParams } from 'url';
|
||||
import DiscordApi from 'discord.js';
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
import App from '../../models/app';
|
||||
import Field from '../../types/field';
|
||||
|
||||
export default class Discord {
|
||||
client?: any
|
||||
connectionData: any
|
||||
appData: any
|
||||
scope: string[] = ['identify', 'email']
|
||||
httpClient: AxiosInstance = axios.create({
|
||||
baseURL: 'https://discord.com/api/'
|
||||
})
|
||||
|
||||
constructor(connectionData: any) {
|
||||
this.connectionData = connectionData;
|
||||
this.appData = App.findOneByKey('discord');
|
||||
}
|
||||
|
||||
get oauthRedirectUrl() {
|
||||
return this.appData.fields.find((field: Field) => field.key == 'oAuthRedirectUrl').value;
|
||||
}
|
||||
|
||||
async createAuthData() {
|
||||
const searchParams = new URLSearchParams({
|
||||
client_id: this.connectionData.consumerKey,
|
||||
redirect_uri: this.oauthRedirectUrl,
|
||||
response_type: 'code',
|
||||
scope: this.scope.join(' '),
|
||||
});
|
||||
|
||||
const url = `https://discord.com/api/oauth2/authorize?${searchParams.toString()}`;
|
||||
|
||||
return { url };
|
||||
}
|
||||
|
||||
async verifyCredentials() {
|
||||
const params = new URLSearchParams({
|
||||
client_id: this.connectionData.consumerKey,
|
||||
redirect_uri: this.oauthRedirectUrl,
|
||||
response_type: 'code',
|
||||
scope: this.scope.join(' '),
|
||||
client_secret: this.connectionData.consumerSecret,
|
||||
code: this.connectionData.oauthVerifier,
|
||||
grant_type: 'authorization_code',
|
||||
});
|
||||
const { data: verifiedCredentials }: any = await this.httpClient.post('/oauth2/token', params.toString());
|
||||
|
||||
const {
|
||||
access_token: accessToken,
|
||||
refresh_token: refreshToken,
|
||||
expires_in: expiresIn,
|
||||
scope: scope,
|
||||
token_type: tokenType,
|
||||
} = verifiedCredentials;
|
||||
|
||||
const { data: user }: any = await this.httpClient.get('/users/@me', {
|
||||
headers: {
|
||||
Authorization: `${tokenType} ${accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
consumerKey: this.connectionData.consumerKey,
|
||||
consumerSecret: this.connectionData.consumerSecret,
|
||||
accessToken,
|
||||
refreshToken,
|
||||
expiresIn,
|
||||
scope,
|
||||
tokenType,
|
||||
userId: user.id,
|
||||
screenName: user.username,
|
||||
email: user.email,
|
||||
};
|
||||
}
|
||||
|
||||
async isStillVerified() {
|
||||
try {
|
||||
await this.httpClient.get('/users/@me', {
|
||||
headers: {
|
||||
Authorization: `${this.connectionData.tokenType} ${this.connectionData.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
return true;
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
218
packages/backend/src/apps/discord/info.json
Normal file
@ -0,0 +1,218 @@
|
||||
{
|
||||
"name": "Discord",
|
||||
"key": "discord",
|
||||
"iconUrl": "{BASE_URL}/apps/discord/assets/favicon.svg",
|
||||
"docUrl": "https://automatisch.io/docs/discord",
|
||||
"primaryColor": "5865f2",
|
||||
"fields": [
|
||||
{
|
||||
"key": "oAuthRedirectUrl",
|
||||
"label": "OAuth Redirect URL",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": true,
|
||||
"value": "https://localhost:3001/app/discord/connections/add",
|
||||
"placeholder": null,
|
||||
"description": "When asked to input an OAuth callback or redirect URL in Discord OAuth, enter the URL above.",
|
||||
"docUrl": "https://automatisch.io/docs/discord#oauth-redirect-url",
|
||||
"clickToCopy": true
|
||||
},
|
||||
{
|
||||
"key": "consumerKey",
|
||||
"label": "Consumer Key",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/discord#consumer-key",
|
||||
"clickToCopy": false
|
||||
},
|
||||
{
|
||||
"key": "consumerSecret",
|
||||
"label": "Consumer Secret",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/discord#consumer-secret",
|
||||
"clickToCopy": false
|
||||
}
|
||||
],
|
||||
"authenticationSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "createConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "key",
|
||||
"value": "{key}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.code}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"reconnectionSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "resetConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.code}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 6,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
35
packages/backend/src/apps/firebase/assets/favicon.svg
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="256px" height="351px" viewBox="0 0 256 351" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
|
||||
<defs>
|
||||
<path d="M1.25273437,280.731641 L2.85834533,277.600858 L102.211177,89.0833546 L58.0613266,5.6082033 C54.3920011,-1.28304578 45.0741245,0.473674398 43.8699203,8.18789086 L1.25273437,280.731641 Z" id="path-1"></path>
|
||||
<filter x="-50%" y="-50%" width="200%" height="200%" filterUnits="objectBoundingBox" id="filter-2">
|
||||
<feGaussianBlur stdDeviation="17.5" in="SourceAlpha" result="shadowBlurInner1"></feGaussianBlur>
|
||||
<feOffset dx="0" dy="0" in="shadowBlurInner1" result="shadowOffsetInner1"></feOffset>
|
||||
<feComposite in="shadowOffsetInner1" in2="SourceAlpha" operator="arithmetic" k2="-1" k3="1" result="shadowInnerInner1"></feComposite>
|
||||
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.06 0" type="matrix" in="shadowInnerInner1"></feColorMatrix>
|
||||
</filter>
|
||||
<path d="M134.417103,148.974235 L166.455722,116.161738 L134.417104,55.1546874 C131.374828,49.3635911 123.983911,48.7568362 120.973828,54.5646483 L103.26875,88.6738296 L102.739423,90.4175473 L134.417103,148.974235 Z" id="path-3"></path>
|
||||
<filter x="-50%" y="-50%" width="200%" height="200%" filterUnits="objectBoundingBox" id="filter-4">
|
||||
<feGaussianBlur stdDeviation="3.5" in="SourceAlpha" result="shadowBlurInner1"></feGaussianBlur>
|
||||
<feOffset dx="1" dy="-9" in="shadowBlurInner1" result="shadowOffsetInner1"></feOffset>
|
||||
<feComposite in="shadowOffsetInner1" in2="SourceAlpha" operator="arithmetic" k2="-1" k3="1" result="shadowInnerInner1"></feComposite>
|
||||
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.09 0" type="matrix" in="shadowInnerInner1"></feColorMatrix>
|
||||
</filter>
|
||||
</defs>
|
||||
<g>
|
||||
<path d="M0,282.99762 L2.12250746,280.0256 L102.527363,89.5119284 L102.739423,87.4951323 L58.478806,4.35817711 C54.7706269,-2.60604179 44.3313035,-0.845245771 43.1143483,6.95065473 L0,282.99762 Z" fill="#FFC24A"></path>
|
||||
<g>
|
||||
<use fill="#FFA712" fill-rule="evenodd" xlink:href="#path-1"></use>
|
||||
<use fill="black" fill-opacity="1" filter="url(#filter-2)" xlink:href="#path-1"></use>
|
||||
</g>
|
||||
<path d="M135.004975,150.380704 L167.960199,116.629461 L134.995423,53.6993114 C131.866109,47.7425353 123.128817,47.7253411 120.032618,53.6993112 L102.421015,87.2880848 L102.421015,90.1487443 L135.004975,150.380704 Z" fill="#F4BD62"></path>
|
||||
<g>
|
||||
<use fill="#FFA50E" fill-rule="evenodd" xlink:href="#path-3"></use>
|
||||
<use fill="black" fill-opacity="1" filter="url(#filter-4)" xlink:href="#path-3"></use>
|
||||
</g>
|
||||
<polygon fill="#F6820C" points="0 282.99762 0.962097168 282.030396 4.45771144 280.60956 132.935323 152.60956 134.563025 148.178595 102.513123 87.1048584"></polygon>
|
||||
<path d="M139.120971,347.551268 L255.395916,282.703666 L222.191698,78.2093373 C221.153051,71.8112478 213.303658,69.2818149 208.724314,73.8694368 L0.000254726368,282.997875 L115.608454,347.545536 C122.914643,351.624979 131.812872,351.62689 139.120971,347.551268" fill="#FDE068"></path>
|
||||
<path d="M254.354084,282.159837 L221.401937,79.2179369 C220.371175,72.8684188 213.843792,70.2409553 209.299213,74.79375 L1.28945312,282.600785 L115.627825,346.509458 C122.878548,350.557931 131.709226,350.559827 138.961846,346.515146 L254.354084,282.159837 Z" fill="#FCCA3F"></path>
|
||||
<path d="M139.120907,345.64082 C131.812808,349.716442 122.914579,349.714531 115.60839,345.635089 L0.93134768,282.014551 L0.000191044776,282.997875 L115.60839,347.545536 C122.914579,351.624979 131.812808,351.62689 139.120907,347.551268 L255.395853,282.703666 L255.111196,280.951785 L139.120907,345.64082 Z" fill="#EEAB37"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.8 KiB |
78
packages/backend/src/apps/firebase/index.ts
Normal file
@ -0,0 +1,78 @@
|
||||
import { google, google as GoogleApi } from 'googleapis';
|
||||
import App from '../../models/app';
|
||||
import Field from '../../types/field';
|
||||
|
||||
export default class Firebase {
|
||||
oauthClient: any
|
||||
connectionData: any
|
||||
appData: any
|
||||
|
||||
scopes: string[] = [
|
||||
'https://www.googleapis.com/auth/datastore',
|
||||
'https://www.googleapis.com/auth/firebase',
|
||||
'https://www.googleapis.com/auth/user.emails.read',
|
||||
'profile',
|
||||
]
|
||||
|
||||
constructor(connectionData: any) {
|
||||
this.appData = App.findOneByKey('firebase');
|
||||
this.connectionData = connectionData;
|
||||
|
||||
this.oauthClient = new GoogleApi.auth.OAuth2(
|
||||
connectionData.consumerKey,
|
||||
connectionData.consumerSecret,
|
||||
this.oauthRedirectUrl,
|
||||
);
|
||||
|
||||
GoogleApi.options({ auth: this.oauthClient });
|
||||
}
|
||||
|
||||
get oauthRedirectUrl() {
|
||||
return this.appData.fields.find((field: Field) => field.key == 'oAuthRedirectUrl').value;
|
||||
}
|
||||
|
||||
async createAuthData() {
|
||||
const url = this.oauthClient.generateAuthUrl({
|
||||
access_type: 'offline',
|
||||
scope: this.scopes
|
||||
});
|
||||
|
||||
return { url };
|
||||
}
|
||||
|
||||
async verifyCredentials() {
|
||||
const { tokens } = await this.oauthClient.getToken(this.connectionData.oauthVerifier);
|
||||
this.oauthClient.setCredentials(tokens);
|
||||
|
||||
const people = GoogleApi.people('v1');
|
||||
|
||||
const { data } = await people.people.get({
|
||||
resourceName: 'people/me',
|
||||
personFields: 'emailAddresses',
|
||||
});
|
||||
|
||||
const { emailAddresses, resourceName: userId } = data;
|
||||
const primaryEmailAddress = emailAddresses.find(emailAddress => emailAddress.metadata.primary);
|
||||
|
||||
return {
|
||||
consumerKey: this.connectionData.consumerKey,
|
||||
consumerSecret: this.connectionData.consumerSecret,
|
||||
accessToken: tokens.access_token,
|
||||
refreshToken: tokens.refresh_token,
|
||||
tokenType: tokens.token_type,
|
||||
expiryDate: tokens.expiry_date,
|
||||
scope: tokens.scope,
|
||||
screenName: primaryEmailAddress.value,
|
||||
userId,
|
||||
}
|
||||
}
|
||||
|
||||
async isStillVerified() {
|
||||
try {
|
||||
await this.oauthClient.getTokenInfo(this.connectionData.accessToken);
|
||||
return true;
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
218
packages/backend/src/apps/firebase/info.json
Normal file
@ -0,0 +1,218 @@
|
||||
{
|
||||
"name": "Firebase",
|
||||
"key": "firebase",
|
||||
"iconUrl": "{BASE_URL}/apps/firebase/assets/favicon.svg",
|
||||
"docUrl": "https://automatisch.io/docs/firebase",
|
||||
"primaryColor": "ffca28",
|
||||
"fields": [
|
||||
{
|
||||
"key": "oAuthRedirectUrl",
|
||||
"label": "OAuth Redirect URL",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": true,
|
||||
"value": "https://localhost:3001/app/firebase/connections/add",
|
||||
"placeholder": null,
|
||||
"description": "When asked to input an OAuth callback or redirect URL in Firebase OAuth, enter the URL above.",
|
||||
"docUrl": "https://automatisch.io/docs/firebase#oauth-redirect-url",
|
||||
"clickToCopy": true
|
||||
},
|
||||
{
|
||||
"key": "consumerKey",
|
||||
"label": "Consumer Key",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/firebase#consumer-key",
|
||||
"clickToCopy": false
|
||||
},
|
||||
{
|
||||
"key": "consumerSecret",
|
||||
"label": "Consumer Secret",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/firebase#consumer-secret",
|
||||
"clickToCopy": false
|
||||
}
|
||||
],
|
||||
"authenticationSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "createConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "key",
|
||||
"value": "{key}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.code}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"reconnectionSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "resetConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.code}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 6,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
5
packages/backend/src/apps/flickr/assets/favicon.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" aria-label="Flickr" role="img" viewBox="0 0 512 512">
|
||||
<rect width="512" height="512" rx="15%" fill="#fff"/>
|
||||
<circle cx="157" cy="256" fill="#0063dc" r="79"/>
|
||||
<circle cx="355" cy="256" fill="#ff0084" r="79"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 261 B |
1
packages/backend/src/apps/flickr/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare module 'flickr-sdk';
|
||||
68
packages/backend/src/apps/flickr/index.ts
Normal file
@ -0,0 +1,68 @@
|
||||
import FlickrApi from 'flickr-sdk';
|
||||
import App from '../../models/app';
|
||||
import Field from '../../types/field';
|
||||
|
||||
export default class Flickr {
|
||||
oauthClient: any
|
||||
client: any
|
||||
connectionData: any
|
||||
appData: any
|
||||
|
||||
constructor(connectionData: any) {
|
||||
this.oauthClient = new FlickrApi.OAuth(connectionData.consumerKey, connectionData.consumerSecret);
|
||||
|
||||
if (connectionData.accessToken && connectionData.accessSecret) {
|
||||
this.client = new FlickrApi(
|
||||
FlickrApi.OAuth.createPlugin(
|
||||
connectionData.consumerKey,
|
||||
connectionData.consumerSecret,
|
||||
connectionData.accessToken,
|
||||
connectionData.accessSecret,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
this.connectionData = connectionData;
|
||||
this.appData = App.findOneByKey('flickr');
|
||||
}
|
||||
|
||||
async createAuthData() {
|
||||
const appFields = this.appData.fields.find((field: Field) => field.key == 'oAuthRedirectUrl')
|
||||
const callbackUrl = appFields.value;
|
||||
|
||||
const oauthData = (await this.oauthClient.request(callbackUrl)).body;
|
||||
const url = await this.oauthClient.authorizeUrl(oauthData.oauth_token, 'delete');
|
||||
|
||||
return {
|
||||
accessToken: oauthData.oauth_token,
|
||||
accessSecret: oauthData.oauth_token_secret,
|
||||
url: url,
|
||||
};
|
||||
}
|
||||
|
||||
async verifyCredentials() {
|
||||
const verifiedCredentials = (await this.oauthClient.verify(
|
||||
this.connectionData.accessToken,
|
||||
this.connectionData.oauthVerifier,
|
||||
this.connectionData.accessSecret
|
||||
)).body;
|
||||
|
||||
return {
|
||||
consumerKey: this.connectionData.consumerKey,
|
||||
consumerSecret: this.connectionData.consumerSecret,
|
||||
accessToken: verifiedCredentials.oauth_token,
|
||||
accessSecret: verifiedCredentials.oauth_token_secret,
|
||||
userId: verifiedCredentials.user_nsid,
|
||||
screenName: verifiedCredentials.fullname
|
||||
}
|
||||
}
|
||||
|
||||
async isStillVerified() {
|
||||
try {
|
||||
await this.client.test.login();
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
218
packages/backend/src/apps/flickr/info.json
Normal file
@ -0,0 +1,218 @@
|
||||
{
|
||||
"name": "Flickr",
|
||||
"key": "flickr",
|
||||
"iconUrl": "{BASE_URL}/apps/flickr/assets/favicon.svg",
|
||||
"docUrl": "https://automatisch.io/docs/flickr",
|
||||
"primaryColor": "000000",
|
||||
"fields": [
|
||||
{
|
||||
"key": "oAuthRedirectUrl",
|
||||
"label": "OAuth Redirect URL",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": true,
|
||||
"value": "http://localhost:3001/app/flickr/connections/add",
|
||||
"placeholder": null,
|
||||
"description": "When asked to input an OAuth callback or redirect URL in Flickr OAuth, enter the URL above.",
|
||||
"docUrl": "https://automatisch.io/docs/flickr#oauth-redirect-url",
|
||||
"clickToCopy": true
|
||||
},
|
||||
{
|
||||
"key": "consumerKey",
|
||||
"label": "Consumer Key",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/flickr#consumer-key",
|
||||
"clickToCopy": false
|
||||
},
|
||||
{
|
||||
"key": "consumerSecret",
|
||||
"label": "Consumer Secret",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/flickr#consumer-secret",
|
||||
"clickToCopy": false
|
||||
}
|
||||
],
|
||||
"authenticationSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "createConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "key",
|
||||
"value": "{key}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.oauth_verifier}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"reconnectionSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "resetConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.oauth_verifier}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 6,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
6
packages/backend/src/apps/github/assets/favicon.svg
Normal file
@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
aria-label="GitHub" role="img"
|
||||
viewBox="0 0 512 512"><rect
|
||||
width="512" height="512"
|
||||
rx="15%"
|
||||
fill="#1B1817"/><path fill="#fff" d="M335 499c14 0 12 17 12 17H165s-2-17 12-17c13 0 16-6 16-12l-1-50c-71 16-86-28-86-28-12-30-28-37-28-37-24-16 1-16 1-16 26 2 40 26 40 26 22 39 59 28 74 22 2-17 9-28 16-35-57-6-116-28-116-126 0-28 10-51 26-69-3-6-11-32 3-67 0 0 21-7 70 26 42-12 86-12 128 0 49-33 70-26 70-26 14 35 6 61 3 67 16 18 26 41 26 69 0 98-60 120-117 126 10 8 18 24 18 48l-1 70c0 6 3 12 16 12z"/></svg>
|
||||
|
After Width: | Height: | Size: 542 B |
77
packages/backend/src/apps/github/index.ts
Normal file
@ -0,0 +1,77 @@
|
||||
import {
|
||||
getWebFlowAuthorizationUrl,
|
||||
exchangeWebFlowCode,
|
||||
checkToken,
|
||||
} from '@octokit/oauth-methods';
|
||||
import App from '../../models/app';
|
||||
import Field from '../../types/field';
|
||||
|
||||
export default class Github {
|
||||
connectionData: any
|
||||
appData: any
|
||||
scopes: string[] = ['repo']
|
||||
|
||||
constructor(connectionData: any) {
|
||||
this.connectionData = connectionData;
|
||||
this.appData = App.findOneByKey('github');
|
||||
}
|
||||
|
||||
get oauthRedirectUrl() {
|
||||
return this.appData.fields.find((field: Field) => field.key == 'oAuthRedirectUrl').value;
|
||||
}
|
||||
|
||||
async createAuthData() {
|
||||
const { url } = await getWebFlowAuthorizationUrl({
|
||||
clientType: "oauth-app",
|
||||
clientId: this.connectionData.consumerKey,
|
||||
redirectUrl: this.oauthRedirectUrl,
|
||||
scopes: this.scopes,
|
||||
});
|
||||
|
||||
return {
|
||||
url: url,
|
||||
};
|
||||
}
|
||||
|
||||
async verifyCredentials() {
|
||||
const { data, authentication } = await exchangeWebFlowCode({
|
||||
clientType: "oauth-app",
|
||||
clientId: this.connectionData.consumerKey,
|
||||
clientSecret: this.connectionData.consumerSecret,
|
||||
code: this.connectionData.oauthVerifier,
|
||||
});
|
||||
|
||||
this.connectionData.accessToken = data.access_token;
|
||||
|
||||
const tokenInfo = await this.getTokenInfo();
|
||||
|
||||
return {
|
||||
consumerKey: this.connectionData.consumerKey,
|
||||
consumerSecret: this.connectionData.consumerSecret,
|
||||
accessToken: data.access_token,
|
||||
scope: data.scope,
|
||||
tokenType: data.token_type,
|
||||
userId: tokenInfo.data.user.id,
|
||||
screenName: tokenInfo.data.user.login,
|
||||
}
|
||||
}
|
||||
|
||||
async getTokenInfo() {
|
||||
return checkToken({
|
||||
clientType: "oauth-app",
|
||||
clientId: this.connectionData.consumerKey,
|
||||
clientSecret: this.connectionData.consumerSecret,
|
||||
token: this.connectionData.accessToken,
|
||||
});
|
||||
}
|
||||
|
||||
async isStillVerified() {
|
||||
try {
|
||||
await this.getTokenInfo();
|
||||
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
218
packages/backend/src/apps/github/info.json
Normal file
@ -0,0 +1,218 @@
|
||||
{
|
||||
"name": "Github",
|
||||
"key": "github",
|
||||
"iconUrl": "{BASE_URL}/apps/github/assets/favicon.svg",
|
||||
"docUrl": "https://automatisch.io/docs/github",
|
||||
"primaryColor": "000000",
|
||||
"fields": [
|
||||
{
|
||||
"key": "oAuthRedirectUrl",
|
||||
"label": "OAuth Redirect URL",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": true,
|
||||
"value": "https://localhost:3001/app/github/connections/add",
|
||||
"placeholder": null,
|
||||
"description": "When asked to input an OAuth callback or redirect URL in Github OAuth, enter the URL above.",
|
||||
"docUrl": "https://automatisch.io/docs/github#oauth-redirect-url",
|
||||
"clickToCopy": true
|
||||
},
|
||||
{
|
||||
"key": "consumerKey",
|
||||
"label": "Consumer Key",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/github#consumer-key",
|
||||
"clickToCopy": false
|
||||
},
|
||||
{
|
||||
"key": "consumerSecret",
|
||||
"label": "Consumer Secret",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/github#consumer-secret",
|
||||
"clickToCopy": false
|
||||
}
|
||||
],
|
||||
"authenticationSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "createConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "key",
|
||||
"value": "{key}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.code}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"reconnectionSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "resetConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.code}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 6,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
6
packages/backend/src/apps/slack/assets/favicon.svg
Normal file
@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
aria-label="Slack" role="img"
|
||||
viewBox="0 0 512 512"><rect
|
||||
width="512" height="512"
|
||||
rx="15%"
|
||||
fill="#fff"/><g fill="#e01e5a"><path id="a" d="M149 305a39 39 0 01-78 0c0-22 17 -39 39 -39h39zM168 305a39 39 0 0178 0v97a39 39 0 01-78 0z"/></g><use xlink:href="#a" fill="#36c5f0" transform="rotate(90,256,256)"/><use xlink:href="#a" fill="#2eb67d" transform="rotate(180,256,256)"/><use xlink:href="#a" fill="#ecb22e" transform="rotate(270,256,256)"/></svg>
|
||||
|
After Width: | Height: | Size: 532 B |
54
packages/backend/src/apps/slack/index.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import { InstallProvider } from '@slack/oauth';
|
||||
import App from '../../models/app';
|
||||
import Field from '../../types/field';
|
||||
|
||||
export default class Slack {
|
||||
client: any
|
||||
connectionData: any
|
||||
appData: any
|
||||
|
||||
scopes: string[] = [
|
||||
'channels:read'
|
||||
]
|
||||
|
||||
constructor(connectionData: any) {
|
||||
this.client = new InstallProvider({
|
||||
clientId: connectionData.consumerKey,
|
||||
clientSecret: connectionData.consumerSecret,
|
||||
stateSecret: 'my-state-secret'
|
||||
});
|
||||
|
||||
this.connectionData = connectionData;
|
||||
this.appData = App.findOneByKey('slack');
|
||||
}
|
||||
|
||||
async createAuthData() {
|
||||
const url = await this.client.generateInstallUrl({
|
||||
scopes: this.scopes
|
||||
})
|
||||
|
||||
return { url }
|
||||
}
|
||||
|
||||
async verifyCredentials() {
|
||||
// const verifiedCredentials = await this.client.login(this.connectionData.oauthVerifier)
|
||||
|
||||
// return {
|
||||
// consumerKey: this.connectionData.consumerKey,
|
||||
// consumerSecret: this.connectionData.consumerSecret,
|
||||
// accessToken: verifiedCredentials.accessToken,
|
||||
// accessSecret: verifiedCredentials.accessSecret,
|
||||
// userId: verifiedCredentials.userId,
|
||||
// screenName: verifiedCredentials.screenName
|
||||
// }
|
||||
}
|
||||
|
||||
async isStillVerified() {
|
||||
// try {
|
||||
// await this.client.currentUser();
|
||||
// return true;
|
||||
// } catch {
|
||||
// return false
|
||||
// }
|
||||
}
|
||||
}
|
||||
218
packages/backend/src/apps/slack/info.json
Normal file
@ -0,0 +1,218 @@
|
||||
{
|
||||
"name": "Slack",
|
||||
"key": "slack",
|
||||
"iconUrl": "{BASE_URL}/apps/slack/assets/favicon.svg",
|
||||
"docUrl": "https://automatisch.io/docs/slack",
|
||||
"primaryColor": "2DAAE1",
|
||||
"fields": [
|
||||
{
|
||||
"key": "oAuthRedirectUrl",
|
||||
"label": "OAuth Redirect URL",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": true,
|
||||
"value": "https://localhost:3001/app/slack/connections/add",
|
||||
"placeholder": null,
|
||||
"description": "When asked to input an OAuth callback or redirect URL in Slack OAuth, enter the URL above.",
|
||||
"docUrl": "https://automatisch.io/docs/slack#oauth-redirect-url",
|
||||
"clickToCopy": true
|
||||
},
|
||||
{
|
||||
"key": "consumerKey",
|
||||
"label": "Client ID",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/slack#client-id",
|
||||
"clickToCopy": false
|
||||
},
|
||||
{
|
||||
"key": "consumerSecret",
|
||||
"label": "Client Secret",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/slack#client-secret",
|
||||
"clickToCopy": false
|
||||
}
|
||||
],
|
||||
"authenticationSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "createConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "key",
|
||||
"value": "{key}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.oauth_verifier}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"reconnectionSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "resetConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.oauth_verifier}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 6,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
6
packages/backend/src/apps/smtp/assets/favicon.svg
Normal file
@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
aria-label="Mail" role="img"
|
||||
viewBox="0 0 512 512"><rect
|
||||
width="512" height="512"
|
||||
rx="15%"
|
||||
fill="#328cff"/><path d="m250 186c-46 0-69 35-69 74 0 44 29 72 68 72 43 0 73-32 73-75 0-44-34-71-72-71zm-1-37c30 0 57 13 77 33 0-22 35-22 35 1v150c-1 10 10 16 16 9 25-25 54-128-14-187-64-56-149-47-195-15-48 33-79 107-49 175 33 76 126 99 182 76 28-12 41 26 12 39-45 19-168 17-225-82-38-68-36-185 67-248 78-46 182-33 244 32 66 69 62 197-2 246-28 23-71 1-71-32v-11c-20 20-47 32-77 32-57 0-108-51-108-108 0-58 51-110 108-110" fill="#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 573 B |
40
packages/backend/src/apps/smtp/index.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import nodemailer from 'nodemailer';
|
||||
import App from '../../models/app';
|
||||
|
||||
export default class SMTP {
|
||||
client: any
|
||||
connectionData: any
|
||||
appData: any
|
||||
|
||||
constructor(connectionData: any) {
|
||||
this.client = nodemailer.createTransport({
|
||||
host: connectionData.host,
|
||||
port: connectionData.port,
|
||||
secure: connectionData.useTls,
|
||||
auth: {
|
||||
user: connectionData.username,
|
||||
pass: connectionData.password,
|
||||
},
|
||||
});
|
||||
|
||||
this.connectionData = connectionData;
|
||||
this.appData = App.findOneByKey('smtp');
|
||||
}
|
||||
|
||||
async verifyCredentials() {
|
||||
await this.client.verify()
|
||||
|
||||
return {
|
||||
screenName: this.connectionData.username
|
||||
}
|
||||
}
|
||||
|
||||
async isStillVerified() {
|
||||
try {
|
||||
await this.client.verify()
|
||||
return true;
|
||||
} catch(error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
200
packages/backend/src/apps/smtp/info.json
Normal file
@ -0,0 +1,200 @@
|
||||
{
|
||||
"name": "SMTP",
|
||||
"key": "smtp",
|
||||
"iconUrl": "{BASE_URL}/apps/smtp/assets/favicon.svg",
|
||||
"docUrl": "https://automatisch.io/docs/smtp",
|
||||
"primaryColor": "2DAAE1",
|
||||
"fields": [
|
||||
{
|
||||
"key": "host",
|
||||
"label": "Host",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": "The host information Automatisch will connect to.",
|
||||
"docUrl": "https://automatisch.io/docs/smtp#host",
|
||||
"clickToCopy": false
|
||||
},
|
||||
{
|
||||
"key": "username",
|
||||
"label": "Email/Username",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": "Your SMTP login credentials.",
|
||||
"docUrl": "https://automatisch.io/docs/smtp#username",
|
||||
"clickToCopy": false
|
||||
},
|
||||
{
|
||||
"key": "password",
|
||||
"label": "Password",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/smtp#password",
|
||||
"clickToCopy": false
|
||||
},
|
||||
{
|
||||
"key": "useTls",
|
||||
"label": "Use TLS?",
|
||||
"type": "boolean",
|
||||
"required": false,
|
||||
"readOnly": false,
|
||||
"value": false,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/smtp#use-tls",
|
||||
"clickToCopy": false
|
||||
},
|
||||
{
|
||||
"key": "port",
|
||||
"label": "Port",
|
||||
"type": "integer",
|
||||
"required": false,
|
||||
"readOnly": false,
|
||||
"value": 25,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/smtp#port",
|
||||
"clickToCopy": false
|
||||
},
|
||||
{
|
||||
"key": "fromEmail",
|
||||
"label": "From Email",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/smtp#from-email",
|
||||
"clickToCopy": false
|
||||
}
|
||||
],
|
||||
"authenticationSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "createConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "key",
|
||||
"value": "{key}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "host",
|
||||
"value": "{fields.host}"
|
||||
},
|
||||
{
|
||||
"name": "username",
|
||||
"value": "{fields.username}"
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"value": "{fields.password}"
|
||||
},
|
||||
{
|
||||
"name": "useTLS",
|
||||
"value": "{fields.useTls}"
|
||||
},
|
||||
{
|
||||
"name": "port",
|
||||
"value": "{fields.port}"
|
||||
},
|
||||
{
|
||||
"name": "fromEmail",
|
||||
"value": "{fields.fromEmail}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"reconnectionSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "resetConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "host",
|
||||
"value": "{fields.host}"
|
||||
},
|
||||
{
|
||||
"name": "username",
|
||||
"value": "{fields.username}"
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"value": "{fields.password}"
|
||||
},
|
||||
{
|
||||
"name": "useTLS",
|
||||
"value": "{fields.useTls}"
|
||||
},
|
||||
{
|
||||
"name": "port",
|
||||
"value": "{fields.port}"
|
||||
},
|
||||
{
|
||||
"name": "fromEmail",
|
||||
"value": "{fields.fromEmail}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
6
packages/backend/src/apps/twilio/assets/favicon.svg
Normal file
@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
aria-label="Twilio" role="img"
|
||||
viewBox="0 0 512 512"><rect
|
||||
width="512" height="512"
|
||||
rx="15%"
|
||||
fill="#fff"/><g fill="#f22f46"><circle cx="256" cy="256" r="256"/><circle cx="256" cy="256" fill="#fff" r="188"/><circle cx="193" cy="193" r="53" id="c"/><use xlink:href="#c" x="126"/><use xlink:href="#c" y="126"/><use xlink:href="#c" x="126" y="126"/></g></svg>
|
||||
|
After Width: | Height: | Size: 438 B |
37
packages/backend/src/apps/twilio/index.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import TwilioApi from 'twilio';
|
||||
import App from '../../models/app';
|
||||
|
||||
export default class Twilio {
|
||||
client: any
|
||||
connectionData: any
|
||||
appData: any
|
||||
|
||||
constructor(connectionData: any) {
|
||||
this.client = TwilioApi(connectionData.accountSid, connectionData.authToken);
|
||||
|
||||
this.connectionData = connectionData;
|
||||
this.appData = App.findOneByKey('twilio');
|
||||
}
|
||||
|
||||
async verifyCredentials() {
|
||||
await this.verify();
|
||||
|
||||
return {
|
||||
screenName: this.connectionData.accountSid
|
||||
}
|
||||
}
|
||||
|
||||
async verify() {
|
||||
try {
|
||||
await this.client.keys.list({ limit: 1 })
|
||||
return true;
|
||||
} catch(error) {
|
||||
// Test credentials throw HTTP 403 and thus, we need to have an exception.
|
||||
return error?.status === 403;
|
||||
}
|
||||
}
|
||||
|
||||
async isStillVerified() {
|
||||
return this.verify();
|
||||
}
|
||||
}
|
||||
120
packages/backend/src/apps/twilio/info.json
Normal file
@ -0,0 +1,120 @@
|
||||
{
|
||||
"name": "Twilio",
|
||||
"key": "twilio",
|
||||
"iconUrl": "{BASE_URL}/apps/twilio/assets/favicon.svg",
|
||||
"docUrl": "https://automatisch.io/docs/twilio",
|
||||
"primaryColor": "f22f46",
|
||||
"fields": [
|
||||
{
|
||||
"key": "accountSid",
|
||||
"label": "Account SID",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": "Log into your Twilio account and find \"API Credentials\" on this page https://www.twilio.com/user/account/settings",
|
||||
"docUrl": "https://automatisch.io/docs/twilio#host",
|
||||
"clickToCopy": false
|
||||
},
|
||||
{
|
||||
"key": "authToken",
|
||||
"label": "Auth Token",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": "Found directly below your Account SID.",
|
||||
"docUrl": "https://automatisch.io/docs/twilio#username",
|
||||
"clickToCopy": false
|
||||
}
|
||||
],
|
||||
"authenticationSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "createConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "key",
|
||||
"value": "{key}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "accountSid",
|
||||
"value": "{fields.accountSid}"
|
||||
},
|
||||
{
|
||||
"name": "authToken",
|
||||
"value": "{fields.authToken}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"reconnectionSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "resetConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "accountSid",
|
||||
"value": "{fields.accountSid}"
|
||||
},
|
||||
{
|
||||
"name": "authToken",
|
||||
"value": "{fields.authToken}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
4
packages/backend/src/apps/twitch/assets/favicon.svg
Normal file
@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" aria-label="Twitch" role="img" viewBox="0 0 512 512">
|
||||
<rect width="512" height="512" rx="15%" fill="#fff"/>
|
||||
<path d="m115 101-22 56v228h78v42h44l41-42h63l85-85v-199zm260 185-48 48h-78l-42 42v-42h-65v-204h233zm-48-100v85h-30v-85zm-78 0v85h-29v-85z" fill="#6441a4"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 316 B |
96
packages/backend/src/apps/twitch/index.ts
Normal file
@ -0,0 +1,96 @@
|
||||
import TwitchApi, { ApiVersions } from 'twitch-js';
|
||||
import fetchUtil from 'twitch-js/lib/utils/fetch';
|
||||
import App from '../../models/app';
|
||||
import Field from '../../types/field';
|
||||
|
||||
type TwitchTokenResponse = {
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
expiresIn: string;
|
||||
tokenType: string;
|
||||
};
|
||||
|
||||
export default class Twitch {
|
||||
client: any
|
||||
connectionData: any
|
||||
appData: any
|
||||
|
||||
constructor(connectionData: any) {
|
||||
this.connectionData = connectionData;
|
||||
this.appData = App.findOneByKey('twitch');
|
||||
|
||||
if (this.clientOptions.token) {
|
||||
this.client = new TwitchApi(this.clientOptions);
|
||||
}
|
||||
}
|
||||
|
||||
get clientOptions() {
|
||||
return {
|
||||
token: this.connectionData.accessToken,
|
||||
clientId: this.connectionData.consumerKey,
|
||||
log: { enabled: true }
|
||||
};
|
||||
}
|
||||
|
||||
get oauthRedirectUrl() {
|
||||
return this.appData.fields.find((field: Field) => field.key == 'oAuthRedirectUrl').value;
|
||||
}
|
||||
|
||||
async createAuthData() {
|
||||
const { url } = await fetchUtil('https://id.twitch.tv/oauth2/authorize', {
|
||||
search: {
|
||||
client_id: this.connectionData.consumerKey,
|
||||
redirect_uri: this.oauthRedirectUrl,
|
||||
response_type: 'code',
|
||||
scope: 'user:read:email',
|
||||
}
|
||||
});
|
||||
|
||||
return { url };
|
||||
}
|
||||
|
||||
async verifyCredentials() {
|
||||
const verifiedCredentials = await fetchUtil('https://id.twitch.tv/oauth2/token', {
|
||||
method: 'post',
|
||||
search: {
|
||||
client_id: this.connectionData.consumerKey,
|
||||
client_secret: this.connectionData.consumerSecret,
|
||||
code: this.connectionData.oauthVerifier,
|
||||
grant_type: 'authorization_code',
|
||||
redirect_uri: this.oauthRedirectUrl
|
||||
}
|
||||
}) as TwitchTokenResponse;
|
||||
|
||||
this.connectionData.accessToken = verifiedCredentials.accessToken;
|
||||
|
||||
const { api } = new TwitchApi(this.clientOptions);
|
||||
|
||||
const { data } = await api.get('users');
|
||||
const [user] = data;
|
||||
|
||||
return {
|
||||
consumerKey: this.connectionData.consumerKey,
|
||||
consumerSecret: this.connectionData.consumerSecret,
|
||||
accessToken: verifiedCredentials.accessToken,
|
||||
refreshToken: verifiedCredentials.refreshToken,
|
||||
expiresIn: verifiedCredentials.expiresIn,
|
||||
tokenType: verifiedCredentials.tokenType,
|
||||
userId: user.id,
|
||||
screenName: user.displayName,
|
||||
}
|
||||
}
|
||||
|
||||
async isStillVerified() {
|
||||
try {
|
||||
await fetchUtil('https://id.twitch.tv/oauth2/userinfo', {
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.connectionData.accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
218
packages/backend/src/apps/twitch/info.json
Normal file
@ -0,0 +1,218 @@
|
||||
{
|
||||
"name": "Twitch",
|
||||
"key": "twitch",
|
||||
"iconUrl": "{BASE_URL}/apps/twitch/assets/favicon.svg",
|
||||
"docUrl": "https://automatisch.io/docs/twitch",
|
||||
"primaryColor": "2DAAE1",
|
||||
"fields": [
|
||||
{
|
||||
"key": "oAuthRedirectUrl",
|
||||
"label": "OAuth Redirect URL",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": true,
|
||||
"value": "https://localhost:3001/app/twitch/connections/add",
|
||||
"placeholder": null,
|
||||
"description": "When asked to input an OAuth callback or redirect URL in Twitch OAuth, enter the URL above.",
|
||||
"docUrl": "https://automatisch.io/docs/twitch#oauth-redirect-url",
|
||||
"clickToCopy": true
|
||||
},
|
||||
{
|
||||
"key": "consumerKey",
|
||||
"label": "Consumer Key",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/twitch#consumer-key",
|
||||
"clickToCopy": false
|
||||
},
|
||||
{
|
||||
"key": "consumerSecret",
|
||||
"label": "Consumer Secret",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/twitch#consumer-secret",
|
||||
"clickToCopy": false
|
||||
}
|
||||
],
|
||||
"authenticationSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "createConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "key",
|
||||
"value": "{key}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.code}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"reconnectionSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "resetConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.code}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 6,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
4
packages/backend/src/apps/twitter/assets/favicon.svg
Normal file
@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" aria-label="Twitter" role="img" viewBox="0 0 512 512">
|
||||
<rect width="512" height="512" rx="15%" fill="#1da1f2"/>
|
||||
<path fill="#fff" d="M437 152a72 72 0 01-40 12a72 72 0 0032-40a72 72 0 01-45 17a72 72 0 00-122 65a200 200 0 01-145-74a72 72 0 0022 94a72 72 0 01-32-7a72 72 0 0056 69a72 72 0 01-32 1a72 72 0 0067 50a200 200 0 01-105 29a200 200 0 00309-179a200 200 0 0035-37"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 422 B |
56
packages/backend/src/apps/twitter/index.ts
Normal file
@ -0,0 +1,56 @@
|
||||
import TwitterApi from 'twitter-api-v2';
|
||||
import App from '../../models/app';
|
||||
import Field from '../../types/field';
|
||||
|
||||
export default class Twitter {
|
||||
client: any
|
||||
connectionData: any
|
||||
appData: any
|
||||
|
||||
constructor(connectionData: any) {
|
||||
this.client = new TwitterApi({
|
||||
appKey: connectionData.consumerKey,
|
||||
appSecret: connectionData.consumerSecret,
|
||||
accessToken: connectionData.accessToken,
|
||||
accessSecret: connectionData.accessSecret
|
||||
});
|
||||
|
||||
this.connectionData = connectionData;
|
||||
this.appData = App.findOneByKey('twitter');
|
||||
}
|
||||
|
||||
async createAuthData() {
|
||||
const appFields = this.appData.fields.find((field: Field) => field.key == 'oAuthRedirectUrl')
|
||||
const callbackUrl = appFields.value;
|
||||
|
||||
const authData = await this.client.generateAuthLink(callbackUrl);
|
||||
|
||||
return {
|
||||
url: authData.url,
|
||||
accessToken: authData.oauth_token,
|
||||
accessSecret: authData.oauth_token_secret,
|
||||
}
|
||||
}
|
||||
|
||||
async verifyCredentials() {
|
||||
const verifiedCredentials = await this.client.login(this.connectionData.oauthVerifier)
|
||||
|
||||
return {
|
||||
consumerKey: this.connectionData.consumerKey,
|
||||
consumerSecret: this.connectionData.consumerSecret,
|
||||
accessToken: verifiedCredentials.accessToken,
|
||||
accessSecret: verifiedCredentials.accessSecret,
|
||||
userId: verifiedCredentials.userId,
|
||||
screenName: verifiedCredentials.screenName
|
||||
}
|
||||
}
|
||||
|
||||
async isStillVerified() {
|
||||
try {
|
||||
await this.client.currentUser();
|
||||
return true;
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
218
packages/backend/src/apps/twitter/info.json
Normal file
@ -0,0 +1,218 @@
|
||||
{
|
||||
"name": "Twitter",
|
||||
"key": "twitter",
|
||||
"iconUrl": "{BASE_URL}/apps/twitter/assets/favicon.svg",
|
||||
"docUrl": "https://automatisch.io/docs/twitter",
|
||||
"primaryColor": "2DAAE1",
|
||||
"fields": [
|
||||
{
|
||||
"key": "oAuthRedirectUrl",
|
||||
"label": "OAuth Redirect URL",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": true,
|
||||
"value": "https://localhost:3001/app/twitter/connections/add",
|
||||
"placeholder": null,
|
||||
"description": "When asked to input an OAuth callback or redirect URL in Twitter OAuth, enter the URL above.",
|
||||
"docUrl": "https://automatisch.io/docs/twitter#oauth-redirect-url",
|
||||
"clickToCopy": true
|
||||
},
|
||||
{
|
||||
"key": "consumerKey",
|
||||
"label": "Consumer Key",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/twitter#consumer-key",
|
||||
"clickToCopy": false
|
||||
},
|
||||
{
|
||||
"key": "consumerSecret",
|
||||
"label": "Consumer Secret",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": false,
|
||||
"value": null,
|
||||
"placeholder": null,
|
||||
"description": null,
|
||||
"docUrl": "https://automatisch.io/docs/twitter#consumer-secret",
|
||||
"clickToCopy": false
|
||||
}
|
||||
],
|
||||
"authenticationSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "createConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "key",
|
||||
"value": "{key}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.oauth_verifier}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{createConnection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"reconnectionSteps": [
|
||||
{
|
||||
"step": 1,
|
||||
"type": "mutation",
|
||||
"name": "resetConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "consumerKey",
|
||||
"value": "{fields.consumerKey}"
|
||||
},
|
||||
{
|
||||
"name": "consumerSecret",
|
||||
"value": "{fields.consumerSecret}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"type": "mutation",
|
||||
"name": "createAuthData",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 4,
|
||||
"type": "openWithPopup",
|
||||
"name": "openAuthPopup",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "url",
|
||||
"value": "{createAuthData.url}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 5,
|
||||
"type": "mutation",
|
||||
"name": "updateConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
},
|
||||
{
|
||||
"name": "data",
|
||||
"value": null,
|
||||
"properties": [
|
||||
{
|
||||
"name": "oauthVerifier",
|
||||
"value": "{openAuthPopup.oauth_verifier}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 6,
|
||||
"type": "mutation",
|
||||
"name": "verifyConnection",
|
||||
"arguments": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{connection.id}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
40
packages/backend/src/config/app.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
|
||||
type AppConfig = {
|
||||
host: string,
|
||||
protocol: string
|
||||
port: string,
|
||||
corsPort: string,
|
||||
corsProtocol: string,
|
||||
appEnv: string,
|
||||
postgresDatabase: string,
|
||||
postgresPort: number,
|
||||
postgresHost: string,
|
||||
postgresUsername: string,
|
||||
postgresPassword: string,
|
||||
baseUrl?: string
|
||||
webAppUrl?: string
|
||||
}
|
||||
|
||||
const appConfig: AppConfig = {
|
||||
host: process.env.HOST || 'localhost',
|
||||
protocol: process.env.PROTOCOL || 'http',
|
||||
port: process.env.PORT || '3000',
|
||||
corsPort: process.env.CORS_PORT || '3001',
|
||||
corsProtocol: process.env.CORS_PROTOCOL || 'http',
|
||||
appEnv: process.env.APP_ENV || 'development',
|
||||
postgresDatabase: process.env.POSTGRES_DATABASE || 'automatisch_development',
|
||||
postgresPort: parseInt(process.env.POSTGRES_PORT) || 5432,
|
||||
postgresHost: process.env.POSTGRES_HOST || 'localhost',
|
||||
postgresUsername: process.env.POSTGRES_USERNAME || 'automatish_development_user',
|
||||
postgresPassword: process.env.POSTGRESS_PASSWORD,
|
||||
}
|
||||
|
||||
const webAppUrl = `${appConfig.corsProtocol}://${appConfig.host}:${appConfig.corsPort}`;
|
||||
appConfig.webAppUrl = webAppUrl;
|
||||
|
||||
const baseUrl = `${appConfig.protocol}://${appConfig.host}:${appConfig.port}`;
|
||||
appConfig.baseUrl = baseUrl;
|
||||
|
||||
export default appConfig;
|
||||
10
packages/backend/src/config/cors-options.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import appConfig from './app'
|
||||
|
||||
const corsOptions = {
|
||||
origin: appConfig.webAppUrl,
|
||||
methods: 'POST',
|
||||
credentials: true,
|
||||
optionsSuccessStatus: 200,
|
||||
}
|
||||
|
||||
export default corsOptions;
|
||||
6
packages/backend/src/config/database.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { Model } from 'objection';
|
||||
import knexInstance from 'knex';
|
||||
import knexConfig from '../../knexfile';
|
||||
|
||||
const knex = knexInstance(knexConfig)
|
||||
Model.knex(knex)
|
||||
@ -0,0 +1,17 @@
|
||||
import { Knex } from "knex";
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
return knex.schema.createTable('users', (table) => {
|
||||
table.increments('id');
|
||||
table.string('email').unique().notNullable();
|
||||
table.string('password').notNullable();
|
||||
|
||||
table.timestamps(true, true);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
export async function down(knex: Knex): Promise<void> {
|
||||
return knex.schema.dropTable('users');
|
||||
}
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
import { Knex } from "knex";
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
return knex.schema.createTable('credentials', (table) => {
|
||||
table.increments('id');
|
||||
table.string('key').notNullable();
|
||||
table.string('display_name').notNullable();
|
||||
table.text('data').notNullable();
|
||||
table.integer('user_id').references('id').inTable('users');
|
||||
table.boolean('verified').defaultTo(false);
|
||||
|
||||
table.timestamps(true, true);
|
||||
});
|
||||
};
|
||||
|
||||
export async function down(knex: Knex): Promise<void> {
|
||||
return knex.schema.dropTable('credentials');
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
import { Knex } from "knex";
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
return knex.schema.table('credentials', (table) => {
|
||||
table.dropColumn('display_name');
|
||||
});
|
||||
}
|
||||
|
||||
export async function down(knex: Knex): Promise<void> {
|
||||
return knex.schema.table('credentials', (table) => {
|
||||
table.string('display_name');
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
import { Knex } from "knex";
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
return knex.schema.renameTable('credentials', 'connections');
|
||||
}
|
||||
|
||||
export async function down(knex: Knex): Promise<void> {
|
||||
return knex.schema.renameTable('connections', 'credentials');
|
||||
}
|
||||
10
packages/backend/src/graphql/graphql-schema.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { GraphQLSchema } from 'graphql';
|
||||
import rootQuery from './root-query';
|
||||
import rootMutation from './root-mutation';
|
||||
|
||||
const graphQLSchema = new GraphQLSchema({
|
||||
query: rootQuery,
|
||||
mutation: rootMutation
|
||||
});
|
||||
|
||||
export default graphQLSchema;
|
||||
42
packages/backend/src/graphql/mutations/create-auth-data.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import { GraphQLNonNull, GraphQLString } from 'graphql';
|
||||
import Connection from '../../models/connection';
|
||||
import authLinkType from '../types/auth-link';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
id: number,
|
||||
}
|
||||
const createAuthDataResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
const connection = await Connection.query().findOne({
|
||||
user_id: req.currentUser.id,
|
||||
id: params.id
|
||||
})
|
||||
|
||||
const appClass = (await import(`../../apps/${connection.key}`)).default;
|
||||
|
||||
const appInstance = new appClass({
|
||||
consumerKey: connection.data.consumerKey,
|
||||
consumerSecret: connection.data.consumerSecret
|
||||
});
|
||||
|
||||
const authLink = await appInstance.createAuthData();
|
||||
|
||||
await connection.$query().patch({
|
||||
data: {
|
||||
...connection.data,
|
||||
...authLink
|
||||
}
|
||||
})
|
||||
|
||||
return authLink;
|
||||
}
|
||||
|
||||
const createAuthData = {
|
||||
type: authLinkType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => createAuthDataResolver(params, req)
|
||||
};
|
||||
|
||||
export default createAuthData;
|
||||
37
packages/backend/src/graphql/mutations/create-connection.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import Connection from '../../models/connection';
|
||||
import App from '../../models/app';
|
||||
import connectionType from '../types/connection';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
import { GraphQLJSONObject } from 'graphql-type-json';
|
||||
|
||||
type Params = {
|
||||
key: string,
|
||||
data: object
|
||||
}
|
||||
const createConnectionResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
console.log('params :', params)
|
||||
|
||||
const app = App.findOneByKey(params.key);
|
||||
const connection = await Connection.query().insert({
|
||||
key: params.key,
|
||||
data: params.data,
|
||||
userId: req.currentUser.id
|
||||
});
|
||||
|
||||
return {
|
||||
...connection,
|
||||
app,
|
||||
};
|
||||
}
|
||||
|
||||
const createConnection = {
|
||||
type: connectionType,
|
||||
args: {
|
||||
key: { type: GraphQLNonNull(GraphQLString) },
|
||||
data: { type: GraphQLNonNull(GraphQLJSONObject) }
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => createConnectionResolver(params, req)
|
||||
};
|
||||
|
||||
export default createConnection;
|
||||
26
packages/backend/src/graphql/mutations/delete-connection.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { GraphQLString, GraphQLNonNull, GraphQLBoolean } from 'graphql';
|
||||
import Connection from '../../models/connection';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
id: string,
|
||||
data: object
|
||||
}
|
||||
const deleteConnectionResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
await Connection.query().delete().findOne({
|
||||
user_id: req.currentUser.id,
|
||||
id: params.id
|
||||
})
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const deleteConnection = {
|
||||
type: GraphQLBoolean,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLString) }
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => deleteConnectionResolver(params, req)
|
||||
};
|
||||
|
||||
export default deleteConnection;
|
||||
31
packages/backend/src/graphql/mutations/reset-connection.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import Connection from '../../models/connection';
|
||||
import connectionType from '../types/connection';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
id: string
|
||||
}
|
||||
|
||||
const resetConnectionResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
let connection = await Connection.query().findOne({
|
||||
user_id: req.currentUser.id,
|
||||
id: params.id
|
||||
})
|
||||
|
||||
connection = await connection.$query().patchAndFetch({
|
||||
data: { screenName: connection.data.screenName }
|
||||
})
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
const resetConnection = {
|
||||
type: connectionType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => resetConnectionResolver(params, req)
|
||||
};
|
||||
|
||||
export default resetConnection;
|
||||
36
packages/backend/src/graphql/mutations/update-connection.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import { GraphQLJSONObject } from 'graphql-type-json';
|
||||
import Connection from '../../models/connection';
|
||||
import connectionType from '../types/connection';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
id: string,
|
||||
data: object
|
||||
}
|
||||
const updateConnectionResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
let connection = await Connection.query().findOne({
|
||||
user_id: req.currentUser.id,
|
||||
id: params.id
|
||||
})
|
||||
|
||||
connection = await connection.$query().patchAndFetch({
|
||||
data: {
|
||||
...connection.data,
|
||||
...params.data
|
||||
}
|
||||
})
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
const updateConnection = {
|
||||
type: connectionType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
data: { type: GraphQLNonNull(GraphQLJSONObject) }
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => updateConnectionResolver(params, req)
|
||||
};
|
||||
|
||||
export default updateConnection;
|
||||
39
packages/backend/src/graphql/mutations/verify-connection.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import Connection from '../../models/connection';
|
||||
import connectionType from '../types/connection';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
id: string
|
||||
}
|
||||
const verifyConnectionResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
let connection = await Connection.query().findOne({
|
||||
user_id: req.currentUser.id,
|
||||
id: params.id
|
||||
})
|
||||
|
||||
const appClass = (await import(`../../apps/${connection.key}`)).default;
|
||||
|
||||
const appInstance = new appClass(connection.data)
|
||||
const verifiedCredentials = await appInstance.verifyCredentials();
|
||||
|
||||
connection = await connection.$query().patchAndFetch({
|
||||
data: {
|
||||
...connection.data,
|
||||
...verifiedCredentials
|
||||
},
|
||||
verified: true
|
||||
})
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
const verifyConnection = {
|
||||
type: connectionType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLString) }
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => verifyConnectionResolver(params, req)
|
||||
};
|
||||
|
||||
export default verifyConnection;
|
||||
30
packages/backend/src/graphql/queries/get-app-connections.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { GraphQLList, GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import Connection from '../../models/connection';
|
||||
import App from '../../models/app';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
import connectionType from '../types/connection';
|
||||
|
||||
type Params = {
|
||||
key: string
|
||||
}
|
||||
|
||||
const getAppConnectionsResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
const app = App.findOneByKey(params.key);
|
||||
const connections = await Connection.query()
|
||||
.where({ user_id: req.currentUser.id, key: params.key })
|
||||
|
||||
return connections.map((connection: any) => ({
|
||||
...connection,
|
||||
app,
|
||||
}));
|
||||
}
|
||||
|
||||
const getAppConnections = {
|
||||
type: GraphQLList(connectionType),
|
||||
args: {
|
||||
key: { type: GraphQLNonNull(GraphQLString) }
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => getAppConnectionsResolver(params, req)
|
||||
}
|
||||
|
||||
export default getAppConnections;
|
||||
40
packages/backend/src/graphql/queries/get-app.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import App from '../../models/app';
|
||||
import appType from '../types/app';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
import Connection from '../../models/connection';
|
||||
import connectionType from '../types/connection';
|
||||
|
||||
type Params = {
|
||||
key: string
|
||||
}
|
||||
|
||||
const getAppResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
if(!params.key) {
|
||||
throw new Error('No key provided.')
|
||||
}
|
||||
|
||||
const app = App.findOneByKey(params.key);
|
||||
|
||||
if (req.currentUser?.id) {
|
||||
const connections = await Connection.query()
|
||||
.where({ user_id: req.currentUser.id, key: params.key });
|
||||
|
||||
return {
|
||||
...app,
|
||||
connections,
|
||||
};
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
const getApp = {
|
||||
type: appType,
|
||||
args: {
|
||||
key: { type: GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => getAppResolver(params, req)
|
||||
}
|
||||
|
||||
export default getApp;
|
||||
21
packages/backend/src/graphql/queries/get-apps.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { GraphQLString, GraphQLList } from 'graphql';
|
||||
import appType from '../types/app';
|
||||
import App from '../../models/app';
|
||||
|
||||
type Params = {
|
||||
name: string
|
||||
}
|
||||
|
||||
const getAppsResolver = (params: Params) => {
|
||||
return App.findAll(params.name)
|
||||
}
|
||||
|
||||
const getApps = {
|
||||
type: GraphQLList(appType),
|
||||
args: {
|
||||
name: { type: GraphQLString }
|
||||
},
|
||||
resolve: (_: any, params: Params) => getAppsResolver(params)
|
||||
}
|
||||
|
||||
export default getApps;
|
||||
43
packages/backend/src/graphql/queries/get-connected-apps.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import { GraphQLList, GraphQLString } from 'graphql';
|
||||
import Connection from '../../models/connection';
|
||||
import App from '../../models/app';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
import appType from '../types/app';
|
||||
|
||||
type Params = {
|
||||
name: string
|
||||
}
|
||||
|
||||
const getConnectedAppsResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
let apps = App.findAll(params.name)
|
||||
|
||||
const connections = await Connection.query()
|
||||
.select('connections.key')
|
||||
.count('connections.id as count')
|
||||
.where({ user_id: req.currentUser.id, verified: true })
|
||||
.groupBy('connections.key')
|
||||
|
||||
const connectionKeys = connections.map(connection => connection.key)
|
||||
|
||||
apps = apps
|
||||
.filter((app: any) => connectionKeys.includes(app.key))
|
||||
.map((app: any) => {
|
||||
const connection = connections
|
||||
.find((connection: any) => connection.key === app.key)
|
||||
|
||||
app.connectionCount = connection.count;
|
||||
return app;
|
||||
})
|
||||
|
||||
return apps;
|
||||
}
|
||||
|
||||
const getConnectedApps = {
|
||||
type: GraphQLList(appType),
|
||||
args: {
|
||||
name: { type: GraphQLString }
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => getConnectedAppsResolver(params, req)
|
||||
}
|
||||
|
||||
export default getConnectedApps;
|
||||
36
packages/backend/src/graphql/queries/test-connection.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { GraphQLString, GraphQLNonNull, GraphQLBoolean } from 'graphql';
|
||||
import Connection from '../../models/connection';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
import connectionType from '../types/connection'
|
||||
|
||||
type Params = {
|
||||
id: string,
|
||||
data: object
|
||||
}
|
||||
const testConnectionResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
let connection = await Connection.query().findOne({
|
||||
user_id: req.currentUser.id,
|
||||
id: params.id
|
||||
})
|
||||
|
||||
const appClass = (await import(`../../apps/${connection.key}`)).default;
|
||||
|
||||
const appInstance = new appClass(connection.data);
|
||||
const isStillVerified = await appInstance.isStillVerified();
|
||||
|
||||
connection = await connection.$query().patchAndFetch({
|
||||
verified: isStillVerified
|
||||
})
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
const testConnection = {
|
||||
type: connectionType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLString) }
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => testConnectionResolver(params, req)
|
||||
};
|
||||
|
||||
export default testConnection;
|
||||
21
packages/backend/src/graphql/root-mutation.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { GraphQLObjectType } from 'graphql';
|
||||
import createConnection from './mutations/create-connection';
|
||||
import createAuthData from './mutations/create-auth-data';
|
||||
import updateConnection from './mutations/update-connection';
|
||||
import resetConnection from './mutations/reset-connection';
|
||||
import verifyConnection from './mutations/verify-connection';
|
||||
import deleteConnection from './mutations/delete-connection';
|
||||
|
||||
const rootMutation = new GraphQLObjectType({
|
||||
name: 'Mutation',
|
||||
fields: {
|
||||
createConnection,
|
||||
createAuthData,
|
||||
updateConnection,
|
||||
resetConnection,
|
||||
verifyConnection,
|
||||
deleteConnection
|
||||
}
|
||||
});
|
||||
|
||||
export default rootMutation;
|
||||
19
packages/backend/src/graphql/root-query.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { GraphQLObjectType } from 'graphql';
|
||||
import getApps from './queries/get-apps';
|
||||
import getApp from './queries/get-app';
|
||||
import getConnectedApps from './queries/get-connected-apps';
|
||||
import getAppConnections from './queries/get-app-connections';
|
||||
import testConnection from './queries/test-connection';
|
||||
|
||||
const rootQuery = new GraphQLObjectType({
|
||||
name: 'Query',
|
||||
fields: {
|
||||
getApps,
|
||||
getApp,
|
||||
getConnectedApps,
|
||||
getAppConnections,
|
||||
testConnection
|
||||
}
|
||||
});
|
||||
|
||||
export default rootQuery;
|
||||
26
packages/backend/src/graphql/types/app.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { GraphQLObjectType, GraphQLString, GraphQLList, GraphQLInt } from 'graphql';
|
||||
import fieldType from './field';
|
||||
import authenticationStepType from './authentication-step';
|
||||
import reconnectionStepType from './reconnection-step';
|
||||
|
||||
const appType = new GraphQLObjectType({
|
||||
name: 'App',
|
||||
fields: () => {
|
||||
const connectionType = require('./connection').default;
|
||||
|
||||
return {
|
||||
name: { type: GraphQLString },
|
||||
key: { type: GraphQLString },
|
||||
connectionCount: { type: GraphQLInt },
|
||||
iconUrl: { type: GraphQLString },
|
||||
docUrl: { type: GraphQLString },
|
||||
primaryColor: { type: GraphQLString },
|
||||
fields: { type: GraphQLList(fieldType) },
|
||||
authenticationSteps: { type: GraphQLList(authenticationStepType) },
|
||||
reconnectionSteps: { type: GraphQLList(reconnectionStepType) },
|
||||
connections: { type: GraphQLList(connectionType) },
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default appType;
|
||||
10
packages/backend/src/graphql/types/auth-link.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { GraphQLObjectType, GraphQLString } from 'graphql';
|
||||
|
||||
const authLinkType = new GraphQLObjectType({
|
||||
name: 'AuthLink',
|
||||
fields: {
|
||||
url: { type: GraphQLString }
|
||||
}
|
||||
})
|
||||
|
||||
export default authLinkType;
|
||||
34
packages/backend/src/graphql/types/authentication-step.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { GraphQLObjectType, GraphQLString, GraphQLList, GraphQLInt } from 'graphql';
|
||||
|
||||
const authenticationStepType = new GraphQLObjectType({
|
||||
name: 'AuthenticationStep',
|
||||
fields: {
|
||||
step: { type: GraphQLInt },
|
||||
type: { type: GraphQLString },
|
||||
name: { type: GraphQLString },
|
||||
arguments: {
|
||||
type: GraphQLList(
|
||||
new GraphQLObjectType({
|
||||
name: 'AuthenticationStepArgument',
|
||||
fields: {
|
||||
name: { type: GraphQLString },
|
||||
value: { type: GraphQLString },
|
||||
properties: {
|
||||
type: GraphQLList(
|
||||
new GraphQLObjectType({
|
||||
name: 'AuthenticationStepProperty',
|
||||
fields: {
|
||||
name: { type: GraphQLString },
|
||||
value: { type: GraphQLString }
|
||||
}
|
||||
})
|
||||
)
|
||||
},
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default authenticationStepType;
|
||||
10
packages/backend/src/graphql/types/connection-data.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { GraphQLString, GraphQLObjectType } from 'graphql';
|
||||
|
||||
const connectionDataType = new GraphQLObjectType({
|
||||
name: 'ConnectionData',
|
||||
fields: {
|
||||
screenName: { type: GraphQLString },
|
||||
}
|
||||
})
|
||||
|
||||
export default connectionDataType;
|
||||
19
packages/backend/src/graphql/types/connection.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { GraphQLObjectType, GraphQLString, GraphQLBoolean } from 'graphql';
|
||||
import connectionDataType from './connection-data';
|
||||
|
||||
const connectionType = new GraphQLObjectType({
|
||||
name: 'Connection',
|
||||
fields: () => {
|
||||
const appType = require('./app').default;
|
||||
|
||||
return {
|
||||
id: { type: GraphQLString },
|
||||
key: { type: GraphQLString },
|
||||
data: { type: connectionDataType },
|
||||
verified: { type: GraphQLBoolean },
|
||||
app: { type: appType }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default connectionType;
|
||||
19
packages/backend/src/graphql/types/field.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { GraphQLObjectType, GraphQLString, GraphQLBoolean} from 'graphql';
|
||||
|
||||
const fieldType = new GraphQLObjectType({
|
||||
name: 'Field',
|
||||
fields: {
|
||||
key: { type: GraphQLString },
|
||||
label: { type: GraphQLString },
|
||||
type: { type: GraphQLString },
|
||||
required: { type: GraphQLBoolean},
|
||||
readOnly: { type: GraphQLBoolean},
|
||||
value: { type: GraphQLString},
|
||||
placeholder: { type: GraphQLString},
|
||||
description: { type: GraphQLString},
|
||||
docUrl: { type: GraphQLString},
|
||||
clickToCopy: { type: GraphQLBoolean},
|
||||
}
|
||||
})
|
||||
|
||||
export default fieldType;
|
||||
34
packages/backend/src/graphql/types/reconnection-step.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { GraphQLObjectType, GraphQLString, GraphQLList, GraphQLInt } from 'graphql';
|
||||
|
||||
const reconnectionStepType = new GraphQLObjectType({
|
||||
name: 'ReconnectionStep',
|
||||
fields: {
|
||||
step: { type: GraphQLInt },
|
||||
type: { type: GraphQLString },
|
||||
name: { type: GraphQLString },
|
||||
arguments: {
|
||||
type: GraphQLList(
|
||||
new GraphQLObjectType({
|
||||
name: 'ReconnectionStepArgument',
|
||||
fields: {
|
||||
name: { type: GraphQLString },
|
||||
value: { type: GraphQLString },
|
||||
properties: {
|
||||
type: GraphQLList(
|
||||
new GraphQLObjectType({
|
||||
name: 'ReconnectionStepProperty',
|
||||
fields: {
|
||||
name: { type: GraphQLString },
|
||||
value: { type: GraphQLString }
|
||||
}
|
||||
})
|
||||
)
|
||||
},
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default reconnectionStepType;
|
||||
15
packages/backend/src/helpers/app-assets-handler.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import express, { Application } from 'express';
|
||||
import App from '../models/app';
|
||||
|
||||
const appAssetsHandler = async (app: Application) => {
|
||||
const appNames = App.list;
|
||||
|
||||
appNames.forEach(appName => {
|
||||
app.use(
|
||||
`/apps/${appName}/assets/favicon.svg`,
|
||||
express.static(`src/apps/${appName}/assets/favicon.svg`)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export default appAssetsHandler;
|
||||
11
packages/backend/src/helpers/app-info-converter.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import AppInfoType from '../types/app-info';
|
||||
import appConfig from '../config/app';
|
||||
|
||||
const appInfoConverter = (rawAppData: string) => {
|
||||
const computedRawData = rawAppData.replace('{BASE_URL}', appConfig.baseUrl);
|
||||
const computedJSONData: AppInfoType = JSON.parse(computedRawData)
|
||||
|
||||
return computedJSONData;
|
||||
}
|
||||
|
||||
export default appInfoConverter;
|
||||
14
packages/backend/src/helpers/authentication.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
import User from '../models/user';
|
||||
import RequestWithCurrentUser from '../types/express/request-with-current-user';
|
||||
|
||||
const authentication = async (req: RequestWithCurrentUser, _res: Response, next: NextFunction) => {
|
||||
// We set authentication to use the sample user we created temporarily.
|
||||
req.currentUser = await User.query().findOne({
|
||||
email: 'user@automatisch.com'
|
||||
})
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
export default authentication;
|
||||
10
packages/backend/src/helpers/eager-load-apps.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import App from '../models/app';
|
||||
import appConfig from '../config/app';
|
||||
|
||||
if(appConfig.appEnv === 'development') {
|
||||
const apps = App.findAll();
|
||||
|
||||
apps.forEach((app: any) => {
|
||||
import(`../apps/${app.key}`);
|
||||
})
|
||||
}
|
||||
13
packages/backend/src/helpers/error-handler.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
import logger from './logger';
|
||||
|
||||
const errorHandler = (err: any, req: Request, res: Response, _next: NextFunction) => {
|
||||
if(err.message === 'Not Found') {
|
||||
res.status(404).end()
|
||||
} else {
|
||||
logger.error(err.message)
|
||||
res.status(500).end()
|
||||
}
|
||||
}
|
||||
|
||||
export default errorHandler;
|
||||
18
packages/backend/src/helpers/graphql-instance.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { graphqlHTTP } from 'express-graphql';
|
||||
import graphQLSchema from '../graphql/graphql-schema'
|
||||
import logger from '../helpers/logger';
|
||||
|
||||
const graphQLInstance = graphqlHTTP({
|
||||
schema: graphQLSchema,
|
||||
graphiql: true,
|
||||
customFormatErrorFn: (error) => {
|
||||
logger.error(error.path + ' : ' + error.message + '\n' + error.stack)
|
||||
|
||||
return {
|
||||
message: error.message,
|
||||
locations: error.locations
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default graphQLInstance;
|
||||
50
packages/backend/src/helpers/logger.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import winston from 'winston'
|
||||
import appConfig from '../config/app'
|
||||
|
||||
const levels = {
|
||||
error: 0,
|
||||
warn: 1,
|
||||
info: 2,
|
||||
http: 3,
|
||||
debug: 4,
|
||||
}
|
||||
|
||||
const level = () => {
|
||||
return appConfig.appEnv === 'development' ? 'debug' : 'warn'
|
||||
}
|
||||
|
||||
const colors = {
|
||||
error: 'red',
|
||||
warn: 'yellow',
|
||||
info: 'green',
|
||||
http: 'magenta',
|
||||
debug: 'white',
|
||||
}
|
||||
|
||||
winston.addColors(colors)
|
||||
|
||||
const format = winston.format.combine(
|
||||
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss:ms' }),
|
||||
winston.format.colorize({ all: true }),
|
||||
winston.format.printf(
|
||||
(info) => `${info.timestamp} [${info.level}]: ${info.message}`,
|
||||
),
|
||||
)
|
||||
|
||||
const transports = [
|
||||
new winston.transports.Console(),
|
||||
new winston.transports.File({
|
||||
filename: 'logs/error.log',
|
||||
level: 'error',
|
||||
}),
|
||||
new winston.transports.File({ filename: 'logs/server.log' }),
|
||||
]
|
||||
|
||||
const logger = winston.createLogger({
|
||||
level: level(),
|
||||
levels,
|
||||
format,
|
||||
transports,
|
||||
})
|
||||
|
||||
export default logger
|
||||
24
packages/backend/src/helpers/morgan.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import morgan, { StreamOptions } from 'morgan';
|
||||
import { Request } from 'express';
|
||||
import logger from './logger';
|
||||
|
||||
const stream: StreamOptions = {
|
||||
write: (message) => logger.http(message.substring(0, message.lastIndexOf("\n")))
|
||||
};
|
||||
|
||||
const registerGraphQLToken = () => {
|
||||
morgan.token("graphql-query", (req: Request) => {
|
||||
if(req.body.query) {
|
||||
return `GraphQL ${req.body.query}`
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
registerGraphQLToken();
|
||||
|
||||
const morganMiddleware = morgan(
|
||||
":method :url :status :res[content-length] - :response-time ms\n:graphql-query",
|
||||
{ stream }
|
||||
);
|
||||
|
||||
export default morganMiddleware;
|
||||
27
packages/backend/src/models/app.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import fs from 'fs';
|
||||
import appInfoConverter from '../helpers/app-info-converter';
|
||||
|
||||
class App {
|
||||
static folderPath = __dirname + '/../apps';
|
||||
static list = fs.readdirSync(this.folderPath);
|
||||
|
||||
static findAll(name?: string): object[] {
|
||||
if(!name) return this.list.map((name) => this.findOneByName(name));
|
||||
|
||||
return this.list
|
||||
.filter((app) => app.includes(name.toLowerCase()))
|
||||
.map((name) => this.findOneByName(name));
|
||||
}
|
||||
|
||||
static findOneByName(name: string): object {
|
||||
const rawAppData = fs.readFileSync(this.folderPath + `/${name}/info.json`, 'utf-8');
|
||||
return appInfoConverter(rawAppData);
|
||||
}
|
||||
|
||||
static findOneByKey(key: string): object {
|
||||
const rawAppData = fs.readFileSync(this.folderPath + `/${key}/info.json`, 'utf-8');
|
||||
return appInfoConverter(rawAppData);
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
||||
25
packages/backend/src/models/base.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { Model, QueryContext, ModelOptions, snakeCaseMappers, ColumnNameMappers } from 'objection';
|
||||
|
||||
class Base extends Model {
|
||||
createdAt!: string;
|
||||
updatedAt!: string;
|
||||
|
||||
static get columnNameMappers(): ColumnNameMappers {
|
||||
return snakeCaseMappers();
|
||||
}
|
||||
|
||||
async $beforeInsert(queryContext: QueryContext) {
|
||||
await super.$beforeInsert(queryContext);
|
||||
|
||||
this.createdAt = new Date().toISOString();
|
||||
this.updatedAt = new Date().toISOString();
|
||||
}
|
||||
|
||||
async $beforeUpdate(opt: ModelOptions, queryContext: QueryContext) {
|
||||
await super.$beforeUpdate(opt, queryContext);
|
||||
|
||||
this.updatedAt = new Date().toISOString();
|
||||
}
|
||||
}
|
||||
|
||||
export default Base;
|
||||
39
packages/backend/src/models/connection.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import Base from './base'
|
||||
import User from './user'
|
||||
|
||||
class Connection extends Base {
|
||||
id!: number
|
||||
key!: string
|
||||
data!: any
|
||||
userId!: number
|
||||
verified: boolean
|
||||
count: number
|
||||
|
||||
static tableName = 'connections';
|
||||
|
||||
static jsonSchema = {
|
||||
type: 'object',
|
||||
required: ['key', 'data', 'userId'],
|
||||
|
||||
properties: {
|
||||
id: { type: 'integer' },
|
||||
key: { type: 'string', minLength: 1, maxLength: 255 },
|
||||
data: { type: 'object' },
|
||||
userId: { type: 'integer' },
|
||||
verified: { type: 'boolean' },
|
||||
}
|
||||
}
|
||||
|
||||
static relationMappings = () => ({
|
||||
user: {
|
||||
relation: Base.BelongsToOneRelation,
|
||||
modelClass: User,
|
||||
join: {
|
||||
from: 'connections.user_id',
|
||||
to: 'users.id',
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default Connection;
|
||||
53
packages/backend/src/models/user.ts
Normal file
@ -0,0 +1,53 @@
|
||||
import { QueryContext, ModelOptions } from 'objection';
|
||||
import Base from './base';
|
||||
import Connection from './connection';
|
||||
import bcrypt from 'bcrypt';
|
||||
|
||||
class User extends Base {
|
||||
id!: number
|
||||
email!: string
|
||||
password!: string
|
||||
|
||||
static tableName = 'users';
|
||||
|
||||
static jsonSchema = {
|
||||
type: 'object',
|
||||
required: ['email', 'password'],
|
||||
|
||||
properties: {
|
||||
id: { type: 'integer' },
|
||||
email: { type: 'string', format: 'email', minLength: 1, maxLength: 255 },
|
||||
password: { type: 'string', minLength: 1, maxLength: 255 },
|
||||
}
|
||||
}
|
||||
|
||||
static relationMappings = () => ({
|
||||
connections: {
|
||||
relation: Base.HasManyRelation,
|
||||
modelClass: Connection,
|
||||
join: {
|
||||
from: 'users.id',
|
||||
to: 'connections.user_id',
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
async generateHash() {
|
||||
this.password = await bcrypt.hash(this.password, 10);
|
||||
}
|
||||
|
||||
async $beforeInsert(queryContext: QueryContext) {
|
||||
await super.$beforeInsert(queryContext);
|
||||
await this.generateHash()
|
||||
}
|
||||
|
||||
async $beforeUpdate(opt: ModelOptions, queryContext: QueryContext) {
|
||||
await super.$beforeUpdate(opt, queryContext);
|
||||
|
||||
if(this.password) {
|
||||
await this.generateHash()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default User;
|
||||
14
packages/backend/src/types/app-info.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import FieldType from './field';
|
||||
import AuthenticationStepType from './authentication-step';
|
||||
|
||||
type AppInfo = {
|
||||
name: string,
|
||||
key: string,
|
||||
iconUrl: string,
|
||||
docUrl: string,
|
||||
primaryColor: string,
|
||||
fields: FieldType[],
|
||||
authenticationSteps?: AuthenticationStepType[]
|
||||
}
|
||||
|
||||
export default AppInfo;
|
||||
10
packages/backend/src/types/authentication-step-field.ts
Normal file
@ -0,0 +1,10 @@
|
||||
type AuthenticationStepField = {
|
||||
name: string,
|
||||
value: string | null,
|
||||
fields?: {
|
||||
name: string,
|
||||
value: string | null
|
||||
}[]
|
||||
}
|
||||
|
||||
export default AuthenticationStepField;
|
||||
10
packages/backend/src/types/authentication-step.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import AuthenticationStepField from '../types/authentication-step-field';
|
||||
|
||||
type AuthenticationStep = {
|
||||
step: number,
|
||||
type: string,
|
||||
name: string,
|
||||
fields: AuthenticationStepField[];
|
||||
}
|
||||
|
||||
export default AuthenticationStep;
|
||||
8
packages/backend/src/types/express/request-with-current-user.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import { Request } from 'express';
|
||||
import User from '../user';
|
||||
|
||||
interface RequestWithCurrentUser extends Request {
|
||||
currentUser: User
|
||||
}
|
||||
|
||||
export default RequestWithCurrentUser;
|
||||
14
packages/backend/src/types/field.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
type Field = {
|
||||
key: string,
|
||||
label: string,
|
||||
type: string,
|
||||
required: boolean,
|
||||
readOnly: boolean,
|
||||
value: string,
|
||||
placeholder: string | null,
|
||||
description: string,
|
||||
docUrl: string,
|
||||
clickToCopy: boolean
|
||||
}
|
||||
|
||||
export default Field;
|
||||
9
packages/backend/src/types/user.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
type User = {
|
||||
id: number,
|
||||
email: string,
|
||||
password: string,
|
||||
createdAt: string,
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export default User;
|
||||
7
packages/backend/test/sample.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import test from 'ava';
|
||||
|
||||
const fn = () => 'foo';
|
||||
|
||||
test('fn() returns foo', t => {
|
||||
t.is(fn(), 'foo');
|
||||
});
|
||||
26
packages/backend/tsconfig.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true,
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"outDir": "dist",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"*": [
|
||||
"node_modules/*",
|
||||
"src/types/*"
|
||||
]
|
||||
},
|
||||
"typeRoots": [
|
||||
"node_modules/@types",
|
||||
"./src/types",
|
||||
"./src/apps"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
||||
0
packages/cli/bin/automatisch
Normal file → Executable file
@ -9,14 +9,14 @@
|
||||
}
|
||||
],
|
||||
"homepage": "https://github.com/automatisch/automatisch#readme",
|
||||
"main": "lib/cli.js",
|
||||
"main": "src/cli.js",
|
||||
"directories": {
|
||||
"bin": "bin",
|
||||
"lib": "lib",
|
||||
"src": "src",
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"src",
|
||||
"bin"
|
||||
],
|
||||
"repository": {
|
||||
|
||||
3
packages/web/.env-example
Normal file
@ -0,0 +1,3 @@
|
||||
PORT=3001
|
||||
REACT_APP_GRAPHQL_URL=http://localhost:3000/graphql
|
||||
HTTPS=true
|
||||
23
packages/web/.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
46
packages/web/README.md
Normal file
@ -0,0 +1,46 @@
|
||||
# Getting Started with Create React App
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `yarn start`
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
|
||||
The page will reload if you make edits.\
|
||||
You will also see any lint errors in the console.
|
||||
|
||||
### `yarn test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `yarn build`
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `yarn eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||
|
||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||
|
||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
70
packages/web/package.json
Normal file
@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "@automatisch/web",
|
||||
"version": "0.1.0",
|
||||
"description": "> TODO: description",
|
||||
"dependencies": {
|
||||
"@apollo/client": "^3.4.15",
|
||||
"@emotion/react": "^11.4.1",
|
||||
"@emotion/styled": "^11.3.0",
|
||||
"@mui/icons-material": "^5.0.1",
|
||||
"@mui/material": "^5.0.2",
|
||||
"@testing-library/jest-dom": "^5.11.4",
|
||||
"@testing-library/react": "^11.1.0",
|
||||
"@testing-library/user-event": "^12.1.10",
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/lodash.template": "^4.5.0",
|
||||
"@types/node": "^12.0.0",
|
||||
"@types/react": "^17.0.0",
|
||||
"@types/react-dom": "^17.0.0",
|
||||
"@types/react-router-dom": "^5.3.0",
|
||||
"clipboard-copy": "^4.0.1",
|
||||
"graphql": "^15.6.0",
|
||||
"lodash.template": "^4.5.0",
|
||||
"notistack": "^2.0.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-hook-form": "^7.17.2",
|
||||
"react-intl": "^5.20.12",
|
||||
"react-router-dom": "^5.3.0",
|
||||
"react-scripts": "4.0.3",
|
||||
"typescript": "^4.1.2",
|
||||
"web-vitals": "^1.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "automatisch contributors",
|
||||
"url": "https://github.com/automatisch/automatisch/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/automatisch/automatisch/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/automatisch/automatisch.git"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
||||
BIN
packages/web/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
48
packages/web/public/index.html
Normal file
@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>Automatisch</title>
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||