.eslintrc.json
.github
    ISSUE_TEMPLATE
        bug_report.md
        content-request.md
        feature_request.md
.vscode
    extensions.json
    launch.json
    my_command.js
    settings.json
README.md
lerna.json
package.json
src
    api
        jest-mongodb-config.js
        jest.config.js
        kubernetesDeployment.json
        kubernetesService.json
        package.json
        src
            constants.ts
            error.ts
            global.d.ts
            helpers
                clone.ts
                dayjs.ts
                firstError.spec.ts
                firstError.ts
                toPublicUser.ts
                typegoose.ts
            index.ts
            logger.ts
            resolvers
                captcha
                    helpers
                        captchaSolutions.ts
                        createCaptcha.ts
                        getRandomCaptchaPair.ts
                near
                    config.ts
                    getReward.ts
                    issueNft.ts
                    nftConfig.ts
                    sendMoney.ts
                page
                    getPublicUser
                        getPublicUser.spec.ts
                        getPublicUser.ts
                    setAccountName
                        setAccountName.ts
                    setName
                        setName.ts
                quota
                    rateLimit
                        rateLimit.spec.ts
                        rateLimit.ts
                user
                    addProgress
                        addProgress.spec.ts
                        addProgress.ts
                    changePassword
                        changePassword.spec.ts
                        changePassword.ts
                    forgotPassword
                        forgotPassword.ts
                    helpers
                        authenticate.spec.ts
                        authenticate.ts
                        getSignedJwt.spec.ts
                        getSignedJwt.ts
                        matchPassword.spec.ts
                        matchPassword.ts
                        sendEmailForgotPassword.ts
                        verifyCaptcha.spec.ts
                        verifyCaptcha.ts
                        verifyRecaptchaToken.spec.ts
                        verifyRecaptchaToken.ts
                        verifySignedJwt.spec.ts
                        verifySignedJwt.ts
                    isCertified
                        isCertified.ts
                    login
                        login.spec.ts
                        login.ts
                    referral
                        getReferralStats.ts
                    resetPassword
                        resetPassword.spec.ts
                        resetPassword.ts
                    signUp
                        signUp.spec.ts
                        signUp.ts
            router.ts
            sanitize.ts
            shared
                captcha
                    Captcha.ts
                    CaptchaFor.ts
                    CaptchaPair.ts
                    CaptchaSolution.ts
                mongo
                    DeleteRes.ts
                    ResponseError.ts
                    UpdateRes.ts
                page
                    GetPublicUser.ts
                    SetAccountName.ts
                    SetName.ts
                quota
                    Quota.ts
                    QuotaRates.ts
                    QuotaType.ts
                referral
                    Referral.ts
                    ReferralStatus.ts
                user
                    AddProgress.ts
                    ChangePassword.ts
                    ForgotPassword.ts
                    IsCertified.ts
                    IsEqualTo.ts
                    Jwt.ts
                    JwtDecoded.ts
                    JwtPayload.ts
                    Login.ts
                    PublicUser.ts
                    ResetPassword.ts
                    SignUp.ts
                    User.ts
                    UserRole.ts
                    VerifyEmail.ts
            test
                createTestUser.ts
                deleteTestUser.ts
                mockConnect.ts
                sleep.ts
        tsconfig.json
    frontend
        kubernetesDeployment.json
        kubernetesService.json
        package.json
        public
            dialog
                happy2029.svg
                jellyfish.svg
                mail.svg
                mario.svg
            distortion-footer.svg
            github.svg
            icons
                badge.svg
                check.svg
                close.svg
                contribute2earn.svg
                dog.svg
                error.svg
                input-error.svg
                input-success.svg
                learn2earn.svg
                nft_certificates.svg
                rocket.svg
                sprites.svg
                success.svg
            images
                Account
                    logout.svg
                    profile.svg
                chapter
                    check.svg
                    check_disabled.svg
                    checked.svg
                header
                    logo-white.svg
                    logo.svg
                museum_exterior_1.svg
                sideMenu
                    arrow.svg
                    checked.svg
                    nearAcademy.svg
                splash
                    bg_transparent.svg
                    close.svg
                    logo-white.svg
                    quote-bg.svg
            index.html
            logo-white.svg
            logo.svg
            man.svg
            manifest.json
            museum_exterior_1.svg
            museum_exterior_animated.svg
            museum_interior_x2.svg
            robots.txt
            telegram.svg
            twitter.svg
        src
            custom-sw.js
            helpers
                dayjs.ts
                domlistener.js
                form.ts
                typegoose.ts
                usePrevious.ts
            pages
                Courses
                    near101
                        Chapters
                            Chapter-1
                                course.md
                                exercise.md
                                index.ts
                                solution.md
                                splash.md
                            Chapter-2
                                course.md
                                index.ts
                                questions.ts
                                splash.md
                            Chapter-3
                                course.md
                                exercise.md
                                index.ts
                                solution.md
                                splash.md
                            Chapter-4
                                course.md
                                index.ts
                                questions.ts
                                splash.md
                            Chapter-5
                                course.md
                                index.ts
                                questions.ts
                                splash.md
                            Chapter-6
                                course.md
                                exercise.md
                                index.ts
                                solution.md
                                splash.md
                            Chapter-7
                                course.md
                                exercise.md
                                index.ts
                                solution.md
                                splash.md
                            Chapter-8
                                course.md
                                exercise.md
                                index.ts
                                solution.md
                                splash.md
                        index.ts
                        module.md
            react-app-env.d.ts
            reducers
                auth.ts
                chapterDrawer.ts
                gdpr.ts
                index.ts
                loading.ts
                loginDrawer.ts
                progressBar.ts
                progressChapter.ts
                serviceWorker.ts
                toaster.ts
                users.ts
            serviceWorker.ts
            setupTests.ts
            shared
                captcha
                    Captcha.ts
                    CaptchaFor.ts
                    CaptchaPair.ts
                    CaptchaSolution.ts
                meme
                    SevenChapterForm.ts
                mongo
                    DeleteRes.ts
                    ResponseError.ts
                    UpdateRes.ts
                page
                    GetPublicUser.ts
                    SetAccountName.ts
                    SetName.ts
                quota
                    Quota.ts
                    QuotaRates.ts
                    QuotaType.ts
                referral
                    Referral.ts
                    ReferralStatus.ts
                user
                    AddProgress.ts
                    ChangePassword.ts
                    ForgotPassword.ts
                    IsCertified.ts
                    IsEqualTo.ts
                    Jwt.ts
                    JwtDecoded.ts
                    JwtPayload.ts
                    Login.ts
                    PublicUser.ts
                    ResetPassword.ts
                    SignUp.ts
                    User.ts
                    UserRole.ts
                    VerifyEmail.ts
            styles
                animations.ts
                colors.ts
                components.ts
                constants.ts
                fonts.css
                global.ts
                index.ts
        tsconfig.json

# near.academy

These instructions are for people on the NEAR Foundation Education team (and aren't necessarily relevant for the general public).

## How to get started

```bash
# 1. Download project
git clone git@github.com:NEAR-Edu/near.academy.git
cd near.academy

# 2. Create .env files
cp src/frontend/.env.example src/frontend/.env
cp src/api/.env.example src/api/.env

# 3. Edit the values in those .env files as appropriate. For example, you'll need to specify the location of your database, etc. If you're on the team responsible for maintaining the official near.academy production site, ask Ryan Walsh or Albert Peci (oceanByte) for the secrets. Do NOT set your local machine to connect to the remote production database!

# 4. Install dependencies for frontend and backend
yarn
# or if your computer uses ARM architecture:
npm i --target_arch=x64

# 5. Install Mongodb:
brew tap mongodb/brew
brew install mongodb-community@5.0
brew services start mongodb/brew/mongodb-community

# 6. Use mongodump to download a "dump" (copy) of the production (remote) database to your local machine:
mongodump --uri "mongodb://usersname:password@127.0.0.1:27100/dbname" --out "/Users/some_username/code/mongodb_dumps_for_near.academy/dump/"

# 7. Rename the local "dump" of the database [so that when you "restore" (create) the database locally, there won't be as much confusion as if it had the same name as the remote production one]:
cd /Users/some_username/code/mongodb_dumps_for_near.academy/dump/
mv nearacademy NearAcademyLocal

# 8. Run mongorestore to convert the local "dump" files into a real, running local database:
cd ..
mongorestore --nsInclude "*.*"

# 8. Start development
yarn start
```

## Deployments

https://dashboard.render.com/ hosts 2 projects, both of which are connected to and depend on this repo.

Pushing commits to `main` will automatically redeploy both the API and frontend projects.

### Frontend 

- "static site" on Render
- Build Command: `cd src/frontend && yarn && yarn build`
- Publish directory: `src/frontend/build`
- Branch: main
- Environment > Environment Variables: manually added one at a time, no Secret Files

### API

- "web service" on Render
- Environment > Secret Files > Filename > `.env`: [paste the .env contents]
- Dockerfile Path: `/src/api/Dockerfile`
- Docker Build Context Directory: `/src/api/`
- Docker Command: (blank)
- Health Check Path: (blank)
- Branch: main

## See also

- https://github.com/NEAR-Edu/near-academy-contracts
- To use `react-google-recaptcha-v3`, you need to generate keys at https://www.google.com/recaptcha/intro/v3.html.
