Skip to content

Commit 4728c46

Browse files
Fix issue with babel transform runtime. Added basic routes for Digimon API. Update Webpack to include babel runtime fix
1 parent e763ad2 commit 4728c46

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"homepage": "https://github.com/erickpeniche/backstop-react-challenge-backend#readme",
2020
"devDependencies": {
2121
"@babel/core": "^7.12.10",
22+
"@babel/plugin-transform-runtime": "^7.12.10",
2223
"@babel/preset-env": "^7.12.11",
2324
"babel-loader": "^8.2.2",
2425
"cross-env": "^7.0.3",
@@ -32,6 +33,7 @@
3233
"webpack-cli": "^4.3.1"
3334
},
3435
"dependencies": {
36+
"@babel/runtime": "^7.12.5",
3537
"cors": "^2.8.5",
3638
"express": "^4.17.1"
3739
}

src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import express from 'express';
22
import cors from 'cors';
3+
import DigimonRoutes from './routes/digimon';
34

45
const app = express();
56
const port = 3000;
67

78
app.use(cors());
9+
app.use('/api/v1/digimon', DigimonRoutes);
810

911
app.listen(port, () => {
1012
console.log(`Back-End listening at http://localhost:${port}`);

src/routes/digimon.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Router } from 'express';
2+
3+
const router = new Router();
4+
5+
export const getAllDigimons = async (req, res) => {
6+
res.json({ test: true });
7+
};
8+
9+
export const getDigimonById = async () => {
10+
11+
};
12+
13+
export const getRandomDigimon = async () => {
14+
15+
};
16+
17+
router.get('/', getAllDigimons);
18+
router.get('/:id', getDigimonById);
19+
router.get('/random', getRandomDigimon);
20+
21+
export default router;

webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module.exports = {
2626
loader: 'babel-loader',
2727
options: {
2828
presets: ['@babel/preset-env'],
29+
plugins: ['@babel/plugin-transform-runtime'],
2930
},
3031
},
3132
],

0 commit comments

Comments
 (0)