Skip to content

Commit

Permalink
fix: re-revert the API decoupling (freeCodeCamp#41263)
Browse files Browse the repository at this point in the history
* fix(api): decouple api from curriculum

This reverts commit 8f0e441 and
introduces the implementations from freeCodeCamp#40703.

* fix(gitpod): add curriculum build to GitPod

This reverts commit 706d70f and
introduces implementations from freeCodeCamp#41234.

* docs: update DevOps manual for api change (freeCodeCamp#41259)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
  • Loading branch information
raisedadead and ojeytonwilliams authored Feb 25, 2021
1 parent 31bdea6 commit b5f4754
Show file tree
Hide file tree
Showing 172 changed files with 381 additions and 349 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
client/.cache/**
client/static/**
client/public/**
api-server/public/**
api-server/src/public/**
api-server/lib/**
tools/contributor/**
7 changes: 4 additions & 3 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
run: |
npm ci
npm run ensure-env
npm run build:curriculum
- name: Seed Database
run: npm run seed
Expand All @@ -60,9 +61,9 @@ jobs:
with:
record: ${{ env.CYPRESS_RECORD_KEY != 0 }}
build: npm run build
# this should mirror the production build, but for now we're just using the dev
# server and gatsby serve instead (the npm script serve:client needs updating!)
start: npm start
# this should mirror the production build, but for now we're using gatsby
# serve instead (the npm script serve:client needs updating!)
start: npm run start-ci
wait-on: http://localhost:8000
# the site builds in about 8 minutes, so there is currently 12 minutes of time
# left for testing.
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/node.js-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
run: |
npm ci
npm run ensure-env
npm run build:curriculum
npm run lint
test:
Expand Down Expand Up @@ -79,6 +80,7 @@ jobs:
run: |
npm ci
npm run ensure-env
npm run build:curriculum
- name: Run Tests
run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ config/env.json
config/client/sass-compile.json
config/client/frame-runner.json
config/client/test-evaluator.json
config/curriculum.json

### Additional Files ###
*.csv
Expand Down
1 change: 1 addition & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ tasks:
mongo --eval "db.fsyncLock(); db.fsyncUnlock()"
command: >
npm run ensure-env &&
npm run build:curriculum &&
gp await-port 27017 &&
npm run develop:server
Expand Down
43 changes: 27 additions & 16 deletions api-server/package-lock.json

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

13 changes: 6 additions & 7 deletions api-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
"version": "0.0.1",
"repository": "freecodecamp/freecodecamp",
"scripts": {
"develop": "cross-env DEBUG=fcc* node development-start.js",
"babel-dev-server": "babel-node --inspect=0.0.0.0 ./server/index.js",
"build": "babel server --out-dir lib --ignore 'node_modules /**/*','/**/*.test.js' --copy-files",
"ensure-env": "node ../tools/scripts/build/ensure-env.js",
"start": "cross-env DEBUG=fcc* node production-start.js",
"develop": "cross-env DEBUG=fcc* node src/development-start.js",
"babel-dev-server": "babel-node --inspect=0.0.0.0 ./src/server/index.js",
"build": "babel src --out-dir lib --ignore 'node_modules /**/*','/**/*.test.js' --copy-files",
"start": "cross-env DEBUG=fcc* node lib/production-start.js",
"test": "jest"
},
"license": "BSD-3-Clause",
Expand All @@ -23,6 +22,7 @@
"connect-mongo": "^3.2.0",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"cross-env": "^7.0.3",
"csurf": "^1.11.0",
"d3": "~3.5.17",
"date-fns": "^1.30.1",
Expand Down Expand Up @@ -51,6 +51,7 @@
"passport-auth0": "^1.4.0",
"passport-local": "^1.0.0",
"query-string": "^6.14.0",
"passport-mock-strategy": "^2.0.0",
"rx": "^4.1.0",
"stripe": "^6.36.0",
"uuid": "^3.4.0",
Expand All @@ -69,11 +70,9 @@
"babel-jest": "^24.9.0",
"babel-plugin-transform-function-bind": "^6.22.0",
"babel-plugin-transform-imports": "^1.5.1",
"cross-env": "^7.0.3",
"jest": "^26.6.3",
"loopback-component-explorer": "^6.4.0",
"nodemon": "^2.0.7",
"passport-mock-strategy": "^2.0.0",
"smee-client": "^1.2.2"
},
"resolutions": {
Expand Down
30 changes: 0 additions & 30 deletions api-server/server/utils/get-curriculum.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import _ from 'lodash';
import generate from 'nanoid/generate';
import badwordFilter from 'bad-words';

import { apiLocation } from '../../../config/env';
import { apiLocation } from '../../../../config/env';

import {
fixCompletedChallengeItem,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
require('dotenv').config({ path: path.resolve(__dirname, '../../.env') });

const nodemon = require('nodemon');
const SmeeClient = require('smee-client');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// this ensures node understands the future
require('@babel/register');
const _ = require('lodash');
const createDebugger = require('debug');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/mstile-70x70.png"/>
<square150x150logo src="/mstile-150x150.png"/>
<square310x310logo src="/mstile-310x310.png"/>
<wide310x150logo src="/mstile-310x150.png"/>
<TileColor>#492c14</TileColor>
</tile>
</msapplication>
</browserconfig>
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/mstile-70x70.png"/>
<square150x150logo src="/mstile-150x150.png"/>
<square310x310logo src="/mstile-310x310.png"/>
<wide310x150logo src="/mstile-310x150.png"/>
<TileColor>#492c14</TileColor>
</tile>
</msapplication>
</browserconfig>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { check } from 'express-validator';
import { isEmail } from 'validator';
import jwt from 'jsonwebtoken';

import { jwtSecret } from '../../../config/secrets';
import { jwtSecret } from '../../../../config/secrets';

import {
createPassportCallbackAuthenticator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
certTypeIdMap,
certIds,
oldDataVizId
} from '../../../config/certification-settings';
} from '../../../../config/certification-settings';

const {
legacyFrontEndChallengeId,
Expand All @@ -42,21 +42,18 @@ const {

const log = debug('fcc:certification');

export default function bootCertificate(app, done) {
export default function bootCertificate(app) {
const api = app.loopback.Router();
// TODO: rather than getting all the challenges, then grabbing the certs,
// consider just getting the certs.
getChallenges().then(allChallenges => {
const certTypeIds = createCertTypeIds(allChallenges);
const showCert = createShowCert(app);
const verifyCert = createVerifyCert(certTypeIds, app);
const certTypeIds = createCertTypeIds(getChallenges());
const showCert = createShowCert(app);
const verifyCert = createVerifyCert(certTypeIds, app);

api.put('/certificate/verify', ifNoUser401, ifNoSuperBlock404, verifyCert);
api.get('/certificate/showCert/:username/:cert', showCert);
api.put('/certificate/verify', ifNoUser401, ifNoSuperBlock404, verifyCert);
api.get('/certificate/showCert/:username/:cert', showCert);

app.use(api);
done();
});
app.use(api);
}

export function getFallbackFrontEndDate(completedChallenges, completedDate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default async function bootChallenge(app, done) {
const api = app.loopback.Router();
const router = app.loopback.Router();
const challengeUrlResolver = await createChallengeUrlResolver(
await getChallenges()
getChallenges()
);
const redirectToCurrentChallenge = createRedirectToCurrentChallenge(
challengeUrlResolver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
durationKeysConfig,
donationOneTimeConfig,
donationSubscriptionConfig
} from '../../../config/donation-settings';
import keys from '../../../config/secrets';
} from '../../../../config/donation-settings';
import keys from '../../../../config/secrets';

const log = debug('fcc:boot:donate');

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import request from 'request';

import { gitHubUserAgent } from '../../../config/misc';
import { gitHubUserAgent } from '../../../../config/misc';
import { getRedirectParams } from '../utils/redirection';

const githubClient = process.env.GITHUB_ID;
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { check } from 'express-validator';
import { ifNoUser401, createValidatorErrorHandler } from '../utils/middleware';
import { themes } from '../../common/utils/themes.js';
import { alertTypes } from '../../common/utils/flash.js';
import { isValidUsername } from '../../../utils/validate';
import { isValidUsername } from '../../../../utils/validate';

const log = debug('fcc:boot:settings');

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import dedent from 'dedent';
import { getUserById } from './utils/user-stats';
import passportProviders from './passport-providers';
import { setAccessTokenToResponse } from './utils/getSetAccessToken';
import { jwtSecret } from '../../config/secrets';
import {
getReturnTo,
getRedirectBase,
getRedirectParams,
isRootPath
} from './utils/redirection';
import { jwtSecret } from '../../../config/secrets';

const passportOptions = {
emailOptional: true,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var secrets = require('../../config/secrets');
var secrets = require('../../../config/secrets');

module.exports = {
db: {
Expand Down
4 changes: 2 additions & 2 deletions api-server/server/index.js → api-server/src/server/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../../.env') });
require('dotenv').config({ path: path.resolve(__dirname, '../../../.env') });

const _ = require('lodash');
const Rx = require('rx');
Expand All @@ -9,7 +9,7 @@ const createDebugger = require('debug');
const morgan = require('morgan');
const Sentry = require('@sentry/node');

const { sentry } = require('../../config/secrets');
const { sentry } = require('../../../config/secrets');
const { setupPassport } = require('./component-passport');

const log = createDebugger('fcc:server');
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit b5f4754

Please sign in to comment.