Skip to content

Commit

Permalink
chore: specify page routes to handle test files while building
Browse files Browse the repository at this point in the history
  • Loading branch information
ijemmao committed Mar 24, 2024
1 parent 82c4d26 commit 1f29c6c
Show file tree
Hide file tree
Showing 17 changed files with 634 additions and 722 deletions.
1 change: 1 addition & 0 deletions functions/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ const withNextra = nextra({
module.exports = withNextra({
distDir: 'dist',
generateBuildId: async () => 'api-homepage',
pageExtensions: ['page.tsx'],
i18n,
});
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ const withNextra = nextra({
module.exports = withNextra({
distDir: 'dist',
generateBuildId: async () => 'api-homepage',
pageExtensions: ['page.tsx'],
i18n,
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"main": "server.js",
"scripts": {
"build": "rm -rf dist/ && npm run build:site && npm run build:src",
"build:functions": "rm -rf functions/src && shx cp -r ./dist ./functions && shx cp -r ./dist/src/dictionaries/ig-en ./functions/dictionaries",
"build:src": "tsc && cross-env NODE_ENV=build npm run build:dictionaries && npm run build:functions",
"build:functions": "rm -rf functions/src && shx cp -r ./dist ./functions && shx cp -r ./dist/src/dictionaries/ig-en ./functions/dictionaries",
"build:dictionaries:ig:en": "[ ! -d \"./dist/src/dictionaries\" ] && shx mkdir ./dist/src/dictionaries || echo '' && [ ! -d \"./dist/src/dictionaries/ig-en\" ] && shx mkdir ./dist/src/dictionaries/ig-en || echo 'Igbo to English dictionaries dir already exists'",
"build:dictionaries:en:ig": "[ ! -d \"./dist/src/dictionaries\" ] && shx mkdir ./dist/src/dictionaries || echo '' && [ ! -d \"./dist/src/dictionaries/en-ig\" ] && shx mkdir ./dist/src/dictionaries/en-ig || echo 'English to Igbo dictionaries dir already exists'",
"build:dictionaries:nsibidi": "[ ! -d \"./dist/src/dictionaries\" ] && shx mkdir ./dist/src/dictionaries || echo '' && [ ! -d \"./dist/src/dictionaries/nsibidi\" ] && shx mkdir ./dist/src/dictionaries/nsibidi || echo 'Nsibidi dictionary dir already exists'",
Expand Down
1 change: 1 addition & 0 deletions src/middleware/validateUpdateDeveloperBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MiddleWare } from '../types';
const developersJoiSchema = Joi.object().keys({
firebaseId: Joi.string().required(),
email: Joi.string().allow('', null).optional(),
displayName: Joi.string().allow('', null).optional(),
});

const validateUpdateDeveloperBody: MiddleWare = (req, res, next) => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/pages/about.tsx → src/pages/about/index.page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { Box, Heading, Text, Link, chakra } from '@chakra-ui/react';
import { FiMail } from 'react-icons/fi';
import Navbar from './components/Navbar';
import Footer from './components/Footer';
import { DICTIONARY_APP_URL } from '../siteConstants';
import Navbar from '../components/Navbar';
import Footer from '../components/Footer';
import { DICTIONARY_APP_URL } from '../../siteConstants';

const About = () => (
<Box className="flex flex-col items-center h-screen">
Expand Down
2 changes: 1 addition & 1 deletion src/pages/dashboard/components/DashboardMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const DashboardMenu = () => {
const router = useRouter();
const logOut = async () => {
try {
await signOut(auth);
signOut(auth);
router.push('/');
} catch (err) {
console.error('Unable to sign out', err);
Expand Down
File renamed without changes.
File renamed without changes.
269 changes: 130 additions & 139 deletions src/pages/privacy.tsx → src/pages/privacy/index.page.tsx

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/pages/signup.tsx → src/pages/signup/index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { createUserWithEmailAndPassword } from 'firebase/auth';
import { useRouter } from 'next/router';
import { useForm, Controller, FieldValues } from 'react-hook-form';
import Login from './login';
import Navbar from './components/Navbar';
import Input from './components/Input';
import { auth } from '../services/firebase';
import { postDeveloper } from './APIs/DevelopersAPI';
import Navbar from '../components/Navbar';
import Input from '../components/Input';
import { auth } from '../../services/firebase';
import { postDeveloper } from '../APIs/DevelopersAPI';

enum AuthState {
SIGNING_IN,
Expand Down
6 changes: 3 additions & 3 deletions src/pages/login.tsx → src/pages/signup/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useRouter } from 'next/router';
import { signInWithPopup, GoogleAuthProvider } from 'firebase/auth';
import Image from 'next/image';
import { Box, Button } from '@chakra-ui/react';
import { auth } from '../services/firebase';
import getAWSAsset from './utils/getAWSAsset';
import { putDeveloper } from './APIs/DevelopersAPI';
import { auth } from '../../services/firebase';
import getAWSAsset from '../utils/getAWSAsset';
import { putDeveloper } from '../APIs/DevelopersAPI';

const provider = new GoogleAuthProvider();

Expand Down
567 changes: 0 additions & 567 deletions src/pages/terms.tsx

This file was deleted.

484 changes: 484 additions & 0 deletions src/pages/terms/index.page.tsx

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/routers/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import rateLimit from 'express-rate-limit';
import { MiddleWare } from '../types';
import { getWords, getWord } from '../controllers/words';
import { getExamples, getExample } from '../controllers/examples';
import { postDeveloper, putDeveloper } from '../controllers/developers';
import { getDeveloper, postDeveloper, putDeveloper } from '../controllers/developers';
import { getStats } from '../controllers/stats';
import validId from '../middleware/validId';
import validateDeveloperBody from '../middleware/validateDeveloperBody';
Expand All @@ -17,7 +17,7 @@ const router = express.Router();

const FIFTEEN_MINUTES = 15 * 60 * 1000;
const REQUESTS_PER_MS = 20;
const createDeveloperLimiter: MiddleWare = rateLimit({
const developerRateLimiter: MiddleWare = rateLimit({
windowMs: FIFTEEN_MINUTES,
max: REQUESTS_PER_MS,
});
Expand All @@ -30,8 +30,9 @@ router.get('/words/:id', validateApiKey, validId, attachRedisClient, getWord);
router.get('/examples', validateApiKey, attachRedisClient, getExamples);
router.get('/examples/:id', validateApiKey, validId, attachRedisClient, getExample);

router.post('/developers', createDeveloperLimiter, validateDeveloperBody, postDeveloper);
router.put('/developers', createDeveloperLimiter, validateUpdateDeveloperBody, putDeveloper);
router.get('/developers/:id', postDeveloper, validateUpdateDeveloperBody, getDeveloper);
router.post('/developers', developerRateLimiter, validateDeveloperBody, postDeveloper);
router.put('/developers', developerRateLimiter, validateUpdateDeveloperBody, putDeveloper);

router.get('/stats', validateAdminApiKey, attachRedisClient, getStats);

Expand Down

0 comments on commit 1f29c6c

Please sign in to comment.