Skip to content

Commit

Permalink
Working concept on moving router things to /core so it's included in …
Browse files Browse the repository at this point in the history
…deployed code. (#377)

Moved infrastructure handlers from devtools to core package and updated serverless paths. Next is to test it in the deployed environment, and eventually roll in webpack.
  • Loading branch information
seanspeaks authored Feb 18, 2025
2 parents d9beefb + b07626c commit 88ef5ee
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 21 deletions.
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { createFriggBackend, Worker } = require('@friggframework/core');
const {
findNearestBackendPackageJson,
} = require('../frigg-cli/utils/backend-path');
} = require('../../devtools/frigg-cli/utils/backend-path');
const path = require('node:path');
const fs = require('fs-extra');

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { createHandler } = require('@friggframework/core');
const { integrationFactory, createQueueWorker } = require('./../backend-utils');
const { integrationFactory, createQueueWorker } = require('../backend-utils');

const handlers = {};
integrationFactory.integrationClasses.forEach((IntegrationClass) => {
Expand Down
21 changes: 6 additions & 15 deletions packages/devtools/infrastructure/serverless-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const composeServerlessDefinition = (AppDefinition) => {
],
},
plugins: [
// 'serverless-webpack',
'serverless-dotenv-plugin',
'serverless-offline-sqs',
'serverless-offline',
Expand Down Expand Up @@ -61,8 +62,7 @@ const composeServerlessDefinition = (AppDefinition) => {
},
functions: {
defaultWebsocket: {
handler:
'/../node_modules/@friggframework/devtools/infrastructure/routers/websocket.handler',
handler: 'node_modules/@friggframework/core/handlers/routers/websocket.handler',
events: [
{
websocket: {
Expand All @@ -82,8 +82,7 @@ const composeServerlessDefinition = (AppDefinition) => {
],
},
auth: {
handler:
'/../node_modules/@friggframework/devtools/infrastructure/routers/auth.handler',
handler: 'node_modules/@friggframework/core/handlers/routers/auth.handler',
events: [
{
http: {
Expand All @@ -109,8 +108,7 @@ const composeServerlessDefinition = (AppDefinition) => {
],
},
user: {
handler:
'/../node_modules/@friggframework/devtools/infrastructure/routers/user.handler',
handler: 'node_modules/@friggframework/core/handlers/routers/user.handler',
events: [
{
http: {
Expand Down Expand Up @@ -218,14 +216,7 @@ const composeServerlessDefinition = (AppDefinition) => {

// Add function for the integration
definition.functions[integrationName] = {
handler: `/../node_modules/@friggframework/devtools/infrastructure/routers/integration-defined-routers.handlers.${integrationName}.handler`,
// events: integration.Definition.routes.map((route) => ({
// http: {
// path: `/api/${integrationName}-integration${route.path}`,
// method: route.method || 'ANY',
// cors: true,
// },
// })),
handler: `node_modules/@friggframework/core/handlers/routers/integration-defined-routers.handlers.${integrationName}.handler`,
events: [
{
http: {
Expand Down Expand Up @@ -260,7 +251,7 @@ const composeServerlessDefinition = (AppDefinition) => {
// Add Queue Worker for the integration
const queueWorkerName = `${integrationName}QueueWorker`;
definition.functions[queueWorkerName] = {
handler: `/../node_modules/@friggframework/devtools/infrastructure/workers/integration-defined-workers.handlers.${integrationName}.queueWorker`,
handler: `node_modules/@friggframework/core/handlers/workers/integration-defined-workers.handlers.${integrationName}.queueWorker`,
reservedConcurrency: 5,
events: [
{
Expand Down
20 changes: 20 additions & 0 deletions packages/devtools/infrastructure/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const slsw = require('serverless-webpack');
const webpack = require('webpack');
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');


module.exports = {
devtool: 'source-map',
entry: slsw.lib.entries,
mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
target: 'node',
externals: ['mongoose', 'express', 'node-fetch'],
plugins: [
// This defines the window global (with value of `undefined`).
new webpack.ProvidePlugin({
window: path.resolve(path.join(__dirname, 'src/utils/webpackFakeWindow')),
}),
]

};
5 changes: 2 additions & 3 deletions packages/devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"@babel/eslint-parser": "^7.18.9",
"@babel/parser": "^7.25.3",
"@babel/traverse": "^7.25.3",
"@friggframework/core": "^2.0.0-next.0",
"@friggframework/test": "^2.0.0-next.0",
"@hapi/boom": "^7.4.11",
"@inquirer/prompts": "^5.3.8",
Expand All @@ -30,11 +29,11 @@
"devDependencies": {
"@friggframework/eslint-config": "^2.0.0-next.0",
"@friggframework/prettier-config": "^2.0.0-next.0",
"serverless": "3.39.0",
"serverless-dotenv-plugin": "^6.0.0",
"serverless-offline": "^13.8.0",
"serverless-offline-sqs": "^8.0.0",
"serverless-webpack": "^5.14.1",
"serverless": "3.39.0"
"serverless-webpack": "^5.14.1"
},
"scripts": {
"lint:fix": "prettier --write --loglevel error . && eslint . --fix",
Expand Down

0 comments on commit 88ef5ee

Please sign in to comment.