diff --git a/packages/text-to-speech/.eslintignore b/packages/text-to-speech/.eslintignore new file mode 100644 index 000000000..c77bedc74 --- /dev/null +++ b/packages/text-to-speech/.eslintignore @@ -0,0 +1,4 @@ +node_modules/ +dist/ +readabilityjs/ +src/generated/ \ No newline at end of file diff --git a/packages/text-to-speech/.eslintrc b/packages/text-to-speech/.eslintrc new file mode 100644 index 000000000..e006282a6 --- /dev/null +++ b/packages/text-to-speech/.eslintrc @@ -0,0 +1,6 @@ +{ + "extends": "../../.eslintrc", + "parserOptions": { + "project": "tsconfig.json" + } +} \ No newline at end of file diff --git a/packages/text-to-speech/.gcloudignore b/packages/text-to-speech/.gcloudignore new file mode 100644 index 000000000..ccc4eb240 --- /dev/null +++ b/packages/text-to-speech/.gcloudignore @@ -0,0 +1,16 @@ +# This file specifies files that are *not* uploaded to Google Cloud Platform +# using gcloud. It follows the same syntax as .gitignore, with the addition of +# "#!include" directives (which insert the entries of the given .gitignore-style +# file at that point). +# +# For more information, run: +# $ gcloud topic gcloudignore +# +.gcloudignore +# If you would like to upload your .git directory, .gitignore file or files +# from your .gitignore file, remove the corresponding line +# below: +.git +.gitignore + +node_modules diff --git a/packages/text-to-speech/mocha-config.json b/packages/text-to-speech/mocha-config.json new file mode 100644 index 000000000..44d1d24c1 --- /dev/null +++ b/packages/text-to-speech/mocha-config.json @@ -0,0 +1,5 @@ +{ + "extension": ["ts"], + "spec": "test/**/*.test.ts", + "require": "test/babel-register.js" + } \ No newline at end of file diff --git a/packages/text-to-speech/package.json b/packages/text-to-speech/package.json new file mode 100644 index 000000000..d55567b35 --- /dev/null +++ b/packages/text-to-speech/package.json @@ -0,0 +1,33 @@ +{ + "name": "@omnivore/text-to-speech-handler", + "version": "1.0.0", + "description": "", + "main": "build/src/index.js", + "types": "build/src/index.d.ts", + "files": [ + "build/src" + ], + "license": "Apache-2.0", + "keywords": [], + "scripts": { + "test": "yarn mocha -r ts-node/register --config mocha-config.json", + "lint": "eslint src --ext ts,js,tsx,jsx", + "compile": "tsc", + "build": "tsc", + "start": "functions-framework --source=build/src/ --target=textToSpeechHandler", + "dev": "concurrently \"tsc -w\" \"nodemon --watch ./build/ --exec npm run start\"", + "gcloud-deploy": "gcloud functions deploy textToSpeechHandler --gen2 --trigger-http --allow-unauthenticated --region=$npm_config_region --runtime nodejs14 --env-vars-file=../gcf-shared/env-$npm_config_env.yaml", + "deploy": "yarn build && yarn gcloud-deploy" + }, + "devDependencies": { + "@types/node": "^14.11.2", + "eslint-plugin-prettier": "^4.0.0" + }, + "dependencies": { + "@google-cloud/functions-framework": "3.1.2", + "@google-cloud/pubsub": "^2.18.4", + "@sentry/serverless": "^6.16.1", + "axios": "^0.27.2", + "jsonwebtoken": "^8.5.1" + } +} diff --git a/packages/text-to-speech/src/index.ts b/packages/text-to-speech/src/index.ts new file mode 100644 index 000000000..06317208e --- /dev/null +++ b/packages/text-to-speech/src/index.ts @@ -0,0 +1,14 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ +/* eslint-disable @typescript-eslint/no-unused-vars */ + +import * as Sentry from '@sentry/serverless' +import parseHeaders from 'parse-headers' + +export const textToSpeechHandler = Sentry.GCPFunction.wrapHttpFunction( + async (req, res) => { + console.log('new request', req) + res.send('OK') + } +) diff --git a/packages/text-to-speech/test/babel-register.js b/packages/text-to-speech/test/babel-register.js new file mode 100644 index 000000000..a6f65f60a --- /dev/null +++ b/packages/text-to-speech/test/babel-register.js @@ -0,0 +1,3 @@ +const register = require('@babel/register').default + +register({ extensions: ['.ts', '.tsx', '.js', '.jsx'] }) diff --git a/packages/text-to-speech/test/stub.test.ts b/packages/text-to-speech/test/stub.test.ts new file mode 100644 index 000000000..173ca4917 --- /dev/null +++ b/packages/text-to-speech/test/stub.test.ts @@ -0,0 +1,13 @@ +import 'mocha' +import * as chai from 'chai' +import { expect } from 'chai' +import 'chai/register-should' +import chaiString from 'chai-string' + +chai.use(chaiString) + +describe('Stub test', () => { + it('should pass', () => { + expect(true).to.be.true + }) +}) diff --git a/packages/text-to-speech/tsconfig.json b/packages/text-to-speech/tsconfig.json new file mode 100644 index 000000000..f450acf38 --- /dev/null +++ b/packages/text-to-speech/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "@tsconfig/node14/tsconfig.json", + "compilerOptions": { + "outDir": "build", + "rootDir": ".", + "lib": ["dom"] + }, + "include": ["src", "test"] +}