Skip to content

Commit

Permalink
first step to bump starter-server
Browse files Browse the repository at this point in the history
  • Loading branch information
tlnd-mhuchet committed Jul 4, 2024
1 parent e618f8e commit 0dc610f
Show file tree
Hide file tree
Showing 16 changed files with 22,026 additions and 14,838 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ coverage
.env.production.local

# generated from the filtered version
component-starter-server/src/main/frontend/package.json
component-tools-webapp/src/main/frontend/package.json
# component-starter-server/src/main/frontend/package.json
# component-tools-webapp/src/main/frontend/package.json
documentation/src/main/frontend/package.json
documentation/src/main/antora/site.yml
documentation/src/main/antora/site-dev.yml
Expand Down
46 changes: 37 additions & 9 deletions component-starter-server/src/main/frontend/backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* 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.
*/const configuration = require('./configuration.json');
*/ const configuration = require('./configuration.json');
const bodyParser = require('body-parser');
const atob = require('atob');

Expand All @@ -33,7 +33,7 @@ function downloadZip(req, res) {
};

const fileName = 'example.zip';
res.sendFile(fileName, options, err => {
res.sendFile(fileName, options, (err) => {
if (err) {
res.status(500).send(err);
} else {
Expand All @@ -47,13 +47,41 @@ function createOnGithub(req, res) {
res.json({ success: true });
}

function setup(app) {
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.get('/api/project/configuration', getConfiguration);
app.post('/api/project/zip/form', downloadZip);
app.post('/api/project/openapi/zip/form', downloadZip);
app.post('/api/project/github', createOnGithub);
function setup(middlewares, devServer) {
if (!devServer) {
throw new Error('webpack-dev-server is not defined');
}

devServer.app.use(bodyParser.urlencoded({ extended: true }));
devServer.app.use(bodyParser.json());

// Use the `unshift` method if you want to run a middleware before all other middlewares
// or when you are migrating from the `onBeforeSetupMiddleware` option
middlewares.unshift({
name: 'project-configuration',
path: '/api/project/configuration',
middleware: getConfiguration,
});

middlewares.unshift({
name: 'project-zip',
path: '/api/project/zip/form',
middleware: downloadZip,
});

middlewares.unshift({
name: 'project-openapi-zip',
path: '/api/project/openapi/zip/form',
middleware: downloadZip,
});

middlewares.unshift({
name: 'project-github',
path: '/api/project/github',
middleware: createOnGithub,
});

return middlewares;
}

module.exports = setup;
Loading

0 comments on commit 0dc610f

Please sign in to comment.