revert(api): decouple api from curriculum

This reverts commit c077ffe4b9
via PR #40703
This commit is contained in:
Mrugesh Mohapatra
2021-02-25 01:46:46 +05:30
committed by Mrugesh Mohapatra
parent 454b267138
commit 8f0e441644
172 changed files with 391 additions and 377 deletions

View File

@ -2,6 +2,6 @@
client/.cache/** client/.cache/**
client/static/** client/static/**
client/public/** client/public/**
api-server/src/public/** api-server/public/**
api-server/lib/** api-server/lib/**
tools/contributor/** tools/contributor/**

View File

@ -51,7 +51,6 @@ jobs:
run: | run: |
npm ci npm ci
npm run ensure-env npm run ensure-env
npm run build:curriculum
- name: Seed Database - name: Seed Database
run: npm run seed run: npm run seed
@ -61,9 +60,9 @@ jobs:
with: with:
record: ${{ env.CYPRESS_RECORD_KEY != 0 }} record: ${{ env.CYPRESS_RECORD_KEY != 0 }}
build: npm run build build: npm run build
# this should mirror the production build, but for now we're using gatsby # this should mirror the production build, but for now we're just using the dev
# serve instead (the npm script serve:client needs updating!) # server and gatsby serve instead (the npm script serve:client needs updating!)
start: npm run start-ci start: npm start
wait-on: http://localhost:8000 wait-on: http://localhost:8000
# the site builds in about 8 minutes, so there is currently 12 minutes of time # the site builds in about 8 minutes, so there is currently 12 minutes of time
# left for testing. # left for testing.

View File

@ -39,7 +39,6 @@ jobs:
run: | run: |
npm ci npm ci
npm run ensure-env --if-present npm run ensure-env --if-present
npm run build:curriculum --if-present
npm run lint --if-present npm run lint --if-present
test: test:
@ -80,7 +79,6 @@ jobs:
run: | run: |
npm ci npm ci
npm run ensure-env --if-present npm run ensure-env --if-present
npm run build:curriculum --if-present
- name: Run Tests - name: Run Tests
run: npm test run: npm test

1
.gitignore vendored
View File

@ -159,7 +159,6 @@ config/env.json
config/client/sass-compile.json config/client/sass-compile.json
config/client/frame-runner.json config/client/frame-runner.json
config/client/test-evaluator.json config/client/test-evaluator.json
config/curriculum.json
### Additional Files ### ### Additional Files ###
*.csv *.csv

View File

@ -15,7 +15,7 @@ import _ from 'lodash';
import generate from 'nanoid/generate'; import generate from 'nanoid/generate';
import badwordFilter from 'bad-words'; import badwordFilter from 'bad-words';
import { apiLocation } from '../../../../config/env'; import { apiLocation } from '../../../config/env';
import { import {
fixCompletedChallengeItem, fixCompletedChallengeItem,

View File

@ -1,5 +1,5 @@
const path = require('path'); 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 nodemon = require('nodemon');
const SmeeClient = require('smee-client'); const SmeeClient = require('smee-client');

View File

@ -4922,9 +4922,10 @@
"dev": true "dev": true
}, },
"@types/passport": { "@types/passport": {
"version": "1.0.5", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/passport/-/passport-1.0.5.tgz", "resolved": "https://registry.npmjs.org/@types/passport/-/passport-1.0.0.tgz",
"integrity": "sha512-wNL4kT/5rnZgyGkqX7V2qH/R/te+bklv+nXcvHzyX99vNggx9DGN+F8CEOW3P/gRi7Cjm991uidRgTHsYkSuMg==", "integrity": "sha512-R2FXqM+AgsMIym0PuKj08Ybx+GR6d2rU3b1/8OcHolJ+4ga2pRPX105wboV6hq1AJvMo2frQzYKdqXS5+4cyMw==",
"dev": true,
"requires": { "requires": {
"@types/express": "*" "@types/express": "*"
} }
@ -4935,11 +4936,6 @@
"integrity": "sha512-UEyp8LwZ4Dg30kVU2Q3amHHyTn1jEdhCIE59ANed76GaT1Vp76DD3ZWSAxgCrw6wJ0TqeoBpqmfUHiUDPs//HQ==", "integrity": "sha512-UEyp8LwZ4Dg30kVU2Q3amHHyTn1jEdhCIE59ANed76GaT1Vp76DD3ZWSAxgCrw6wJ0TqeoBpqmfUHiUDPs//HQ==",
"dev": true "dev": true
}, },
"@types/qs": {
"version": "6.9.5",
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.5.tgz",
"integrity": "sha512-/JHkVHtx/REVG0VVToGRGH2+23hsYLHdyG+GrvoUGlGAd0ErauXDyvHtRI/7H7mzLm+tBCKA7pfcpkQ1lf58iQ=="
},
"@types/range-parser": { "@types/range-parser": {
"version": "1.2.2", "version": "1.2.2",
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.2.tgz", "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.2.tgz",
@ -6462,6 +6458,7 @@
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
"integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==",
"dev": true,
"requires": { "requires": {
"cross-spawn": "^7.0.1" "cross-spawn": "^7.0.1"
} }
@ -6911,11 +6908,6 @@
"is-symbol": "^1.0.2" "is-symbol": "^1.0.2"
} }
}, },
"es6-promise": {
"version": "4.2.8",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz",
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w=="
},
"es6-promisify": { "es6-promisify": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz",
@ -15184,6 +15176,7 @@
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/passport-mock-strategy/-/passport-mock-strategy-2.0.0.tgz", "resolved": "https://registry.npmjs.org/passport-mock-strategy/-/passport-mock-strategy-2.0.0.tgz",
"integrity": "sha512-9YUT0sja/7n+HfQ+Jwx4XETERRh1uciRjpHhEZMcYS1FBnMrfrSlKVS42bMU06ewSFiPhXztazAE6XwiZdZQ/g==", "integrity": "sha512-9YUT0sja/7n+HfQ+Jwx4XETERRh1uciRjpHhEZMcYS1FBnMrfrSlKVS42bMU06ewSFiPhXztazAE6XwiZdZQ/g==",
"dev": true,
"requires": { "requires": {
"@types/express": "^4.16.1", "@types/express": "^4.16.1",
"@types/passport": "^1.0.0", "@types/passport": "^1.0.0",
@ -15192,25 +15185,21 @@
}, },
"dependencies": { "dependencies": {
"@types/express": { "@types/express": {
"version": "4.17.11", "version": "4.17.0",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.11.tgz", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.0.tgz",
"integrity": "sha512-no+R6rW60JEc59977wIxreQVsIEOAYwgCqldrA/vkpCnbD7MqTefO97lmoBe4WE0F156bC4uLSP1XHDOySnChg==", "integrity": "sha512-CjaMu57cjgjuZbh9DpkloeGxV45CnMGlVd+XpG7Gm9QgVrd7KFq+X4HY0vM+2v0bczS48Wg7bvnMY5TN+Xmcfw==",
"dev": true,
"requires": { "requires": {
"@types/body-parser": "*", "@types/body-parser": "*",
"@types/express-serve-static-core": "^4.17.18", "@types/express-serve-static-core": "*",
"@types/qs": "*",
"@types/serve-static": "*" "@types/serve-static": "*"
} }
}, },
"@types/express-serve-static-core": { "es6-promise": {
"version": "4.17.18", "version": "4.2.8",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.18.tgz", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz",
"integrity": "sha512-m4JTwx5RUBNZvky/JJ8swEJPKFd8si08pPF2PfizYjGZOKr/svUWPcoUmLow6MmPzhasphB7gSTINY67xn3JNA==", "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==",
"requires": { "dev": true
"@types/node": "*",
"@types/qs": "*",
"@types/range-parser": "*"
}
} }
} }
}, },

View File

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

View File

@ -1,4 +1,5 @@
// this ensures node understands the future // this ensures node understands the future
require('@babel/register');
const _ = require('lodash'); const _ = require('lodash');
const createDebugger = require('debug'); const createDebugger = require('debug');

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -4,7 +4,7 @@ import { check } from 'express-validator';
import { isEmail } from 'validator'; import { isEmail } from 'validator';
import jwt from 'jsonwebtoken'; import jwt from 'jsonwebtoken';
import { jwtSecret } from '../../../../config/secrets'; import { jwtSecret } from '../../../config/secrets';
import { import {
createPassportCallbackAuthenticator, createPassportCallbackAuthenticator,

View File

@ -20,7 +20,7 @@ import {
certTypeIdMap, certTypeIdMap,
certIds, certIds,
oldDataVizId oldDataVizId
} from '../../../../config/certification-settings'; } from '../../../config/certification-settings';
const { const {
legacyFrontEndChallengeId, legacyFrontEndChallengeId,
@ -42,11 +42,12 @@ const {
const log = debug('fcc:certification'); const log = debug('fcc:certification');
export default function bootCertificate(app) { export default function bootCertificate(app, done) {
const api = app.loopback.Router(); const api = app.loopback.Router();
// TODO: rather than getting all the challenges, then grabbing the certs, // TODO: rather than getting all the challenges, then grabbing the certs,
// consider just getting the certs. // consider just getting the certs.
const certTypeIds = createCertTypeIds(getChallenges()); getChallenges().then(allChallenges => {
const certTypeIds = createCertTypeIds(allChallenges);
const showCert = createShowCert(app); const showCert = createShowCert(app);
const verifyCert = createVerifyCert(certTypeIds, app); const verifyCert = createVerifyCert(certTypeIds, app);
@ -54,6 +55,8 @@ export default function bootCertificate(app) {
api.get('/certificate/showCert/:username/:cert', showCert); api.get('/certificate/showCert/:username/:cert', showCert);
app.use(api); app.use(api);
done();
});
} }
export function getFallbackFrontEndDate(completedChallenges, completedDate) { export function getFallbackFrontEndDate(completedChallenges, completedDate) {

View File

@ -28,7 +28,7 @@ export default async function bootChallenge(app, done) {
const api = app.loopback.Router(); const api = app.loopback.Router();
const router = app.loopback.Router(); const router = app.loopback.Router();
const challengeUrlResolver = await createChallengeUrlResolver( const challengeUrlResolver = await createChallengeUrlResolver(
getChallenges() await getChallenges()
); );
const redirectToCurrentChallenge = createRedirectToCurrentChallenge( const redirectToCurrentChallenge = createRedirectToCurrentChallenge(
challengeUrlResolver, challengeUrlResolver,

View File

@ -12,8 +12,8 @@ import {
durationKeysConfig, durationKeysConfig,
donationOneTimeConfig, donationOneTimeConfig,
donationSubscriptionConfig donationSubscriptionConfig
} from '../../../../config/donation-settings'; } from '../../../config/donation-settings';
import keys from '../../../../config/secrets'; import keys from '../../../config/secrets';
const log = debug('fcc:boot:donate'); const log = debug('fcc:boot:donate');

View File

@ -1,6 +1,6 @@
import request from 'request'; import request from 'request';
import { gitHubUserAgent } from '../../../../config/misc'; import { gitHubUserAgent } from '../../../config/misc';
import { getRedirectParams } from '../utils/redirection'; import { getRedirectParams } from '../utils/redirection';
const githubClient = process.env.GITHUB_ID; const githubClient = process.env.GITHUB_ID;

View File

@ -4,7 +4,7 @@ import { check } from 'express-validator';
import { ifNoUser401, createValidatorErrorHandler } from '../utils/middleware'; import { ifNoUser401, createValidatorErrorHandler } from '../utils/middleware';
import { themes } from '../../common/utils/themes.js'; import { themes } from '../../common/utils/themes.js';
import { alertTypes } from '../../common/utils/flash.js'; import { alertTypes } from '../../common/utils/flash.js';
import { isValidUsername } from '../../../../utils/validate'; import { isValidUsername } from '../../../utils/validate';
const log = debug('fcc:boot:settings'); const log = debug('fcc:boot:settings');

View File

@ -9,13 +9,13 @@ import dedent from 'dedent';
import { getUserById } from './utils/user-stats'; import { getUserById } from './utils/user-stats';
import passportProviders from './passport-providers'; import passportProviders from './passport-providers';
import { setAccessTokenToResponse } from './utils/getSetAccessToken'; import { setAccessTokenToResponse } from './utils/getSetAccessToken';
import { jwtSecret } from '../../config/secrets';
import { import {
getReturnTo, getReturnTo,
getRedirectBase, getRedirectBase,
getRedirectParams, getRedirectParams,
isRootPath isRootPath
} from './utils/redirection'; } from './utils/redirection';
import { jwtSecret } from '../../../config/secrets';
const passportOptions = { const passportOptions = {
emailOptional: true, emailOptional: true,

View File

@ -1,4 +1,4 @@
var secrets = require('../../../config/secrets'); var secrets = require('../../config/secrets');
module.exports = { module.exports = {
db: { db: {

View File

@ -1,5 +1,5 @@
const path = require('path'); const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../../../.env') }); require('dotenv').config({ path: path.resolve(__dirname, '../../.env') });
const _ = require('lodash'); const _ = require('lodash');
const Rx = require('rx'); const Rx = require('rx');
@ -9,7 +9,7 @@ const createDebugger = require('debug');
const morgan = require('morgan'); const morgan = require('morgan');
const Sentry = require('@sentry/node'); const Sentry = require('@sentry/node');
const { sentry } = require('../../../config/secrets'); const { sentry } = require('../../config/secrets');
const { setupPassport } = require('./component-passport'); const { setupPassport } = require('./component-passport');
const log = createDebugger('fcc:server'); const log = createDebugger('fcc:server');

View File

@ -1,5 +1,5 @@
import { homeLocation } from '../../../../config/env'; import { homeLocation } from '../../../config/env';
import { allowedOrigins } from '../../../../config/cors-settings'; import { allowedOrigins } from '../../../config/cors-settings';
export default function constantHeaders() { export default function constantHeaders() {
return function(req, res, next) { return function(req, res, next) {

View File

@ -1,6 +1,6 @@
import helmet from 'helmet'; import helmet from 'helmet';
import { homeLocation } from '../../../../config/env'; import { homeLocation } from '../../../config/env';
let trusted = [ let trusted = [
"'self'", "'self'",

View File

@ -6,7 +6,7 @@ import {
errorTypes, errorTypes,
authHeaderNS authHeaderNS
} from '../utils/getSetAccessToken'; } from '../utils/getSetAccessToken';
import { jwtSecret as _jwtSecret } from '../../../../config/secrets'; import { jwtSecret as _jwtSecret } from '../../../config/secrets';
import { wrapHandledError } from '../utils/create-handled-error'; import { wrapHandledError } from '../utils/create-handled-error';
import { getRedirectParams } from '../utils/redirection'; import { getRedirectParams } from '../utils/redirection';

View File

@ -3,7 +3,7 @@ import sinon from 'sinon';
import { mockReq as mockRequest, mockRes } from 'sinon-express-mock'; import { mockReq as mockRequest, mockRes } from 'sinon-express-mock';
import jwt from 'jsonwebtoken'; import jwt from 'jsonwebtoken';
import { homeLocation } from '../../../../config/env'; import { homeLocation } from '../../../config/env.json';
import createRequestAuthorization, { import createRequestAuthorization, {
isAllowedPath isAllowedPath
} from './request-authorization'; } from './request-authorization';

Some files were not shown because too many files have changed in this diff Show More