AstroAsh
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # prereqCheck [![Build Status](https://travis-ci.org/ameliejyc/prereq-check.svg?branch=master)](https://travis-ci.org/ameliejyc/prereq-check) [![codecov](https://codecov.io/gh/ameliejyc/prereq-check/branch/master/graph/badge.svg)](https://codecov.io/gh/ameliejyc/prereq-check) A prerequisite checker for FAC applications :heavy_check_mark: ## Why The selection committee needs to be able to easily see how applicants have done with their prerequisites. Applicants also need to see how they are doing as they work through them. This should be as transparent as possible so that applicants know what they're being judged on. Currently applications are saved into a Google Sheet, where some useful macros are used to help streamline the process. However it is still very tedious for the selection committee to sift through each applicant, as they have to click through to the applicant's various profiles on Github, Codewars, freeCodeCamp etc. ## What preReqCheck is a place where an applicant's progress on the prequisites can all be seen in one place. After signing in with GitHub, an applicant can enter their own GitHub Pages site url and then scroll through their current progress in the various prerequisites, as well as some extra information which is used by the selection panel. Selection panel members can see the same information, but for any applicant. ### User Stories #### As a selection panel member I can: - [x] See whether the applicant has attained 5 Kyu. - [x] See whether the applicant has authored a kata. - [x] See whether the applicant has completed the 4 subsections on freeCodeCamp. - [x] See whether the applicant has created a website hosted on github pages. - [x] Input the URL of an applicant's GitHub page in order to see their prerequisite information. - [x] See extra information about an applicant's Codewars profile. - [x] See an applicants points score on freecodecamp. - [x] See more detail about an applicants github page and github usage. - [ ] Login with my GitHub account to access the app. - [ ] See info about an applicants meetup attendance. - [ ] Navigate between all areas of prerequisite information easily. - [ ] Logout from the app. #### As an applicant I can: - [x] See whether I have attained 5 Kyu. - [x] See whether I have authored a kata. - [x] See whether I have completed the 4 subsections on freeCodeCamp. - [x] See confirmation that I have created a website hosted on github pages. - [x] Input the URL of my GitHub page in order to see my prerequisite information. - [x] See extra information about my Codewars profile. - [x] See my 'points score' from my freecodecamp account. - [x] See more detail about my github page and usage. - [ ] Login with my GitHub account to access the app. - [ ] See info about my meetup attendance. - [ ] Navigate around all areas of my information easily. - [ ] Logout from the app. ## How to set up Locally To set up locally, first clone this repo: ```git clone https://github.com/ameliejyc/prereq-check.git``` Use `npm run devStart` to start the dev server. Or to run tests: `npm test`. ## How & Things We Learned ### Stack * JavaScript * SCSS & Handlebars * Node.js & Express.js ### Promises As this project relies on numerous api calls to be made to return data we have used promises to simply this process. ```Promise.all``` is used to allow us to send all the api calls off in one go, and only render the page on return of them all. As the project also requires some page crawling, the node module request-promise is also used to return a page's HTML content as a string: ``` rp('http://www.google.com') .then(function (htmlString) { // Process html... }) .catch(function (err) { // Crawling failed... }); ``` ### Nock for mocking HTTP requests prereqCheck makes multiple API calls, and HTTP calls to webpages. Including actual live network requests in tests is problematic because: * there may be limitations on the frequency of API calls; * tests may fail as a result of network of other errors extraneous to the codebase. [Nock](https://github.com/node-nock/nock) is an npm module that facilitates the 'mocking' of HTTP requests. It will intercept any outgoing requests to a defined url, and respond with the data which you give it. For example, in the test below *nock* intercepts any request to the defined domain passed to ```nock```, and responds with the contents of the file passed to ```replyWithFile()```. ```js tape('Codewars API: getCodewars invalid username', (t) => { const username = 'astroashaaa'; nock('https://www.codewars.com/') .get(`/api/v1/users/${username}`) # <--- MUST start with a / .replyWithFile(404, path.join(__dirname, 'dummy-data', 'codewars-response-fail.json')); getCodewars(username) .then((response) => { t.deepEqual(response, { success: false, statusCode: 404, message: 'User not found', }, 'getCodewars for invalid username returns correct object'); t.end(); }); }) ``` ### SASS/SCSS prereqCheck uses SCSS to add functionality to CSS predominantly by making use of variables. SCSS, or Sassy CSS, is a syntax of SASS and is a superset of CSS3’s syntax. This means that every valid CSS3 stylesheet is valid SCSS as well. prereqCheck uses the node module node-sass to compile .scss files to browser-readable .css files. By combining a watch script using nodemon with a build script using node-sass, we are able to watch and build our main.css file on every change using an npm script. ``` “scripts”: { “build-css”: “node-sass --include-path scss scss/main.scss public/css/main.css”, “watch-css”: “nodemon -e scss -x \”npm run build-css\”” } ``` ### Testing authenticated routes Helper function to get valid cookie: (TODO: this needs comments and boiling down) ``` const getCookies = (cb) => { nock('https://github.com/login/oauth/access_token') .get(/.*/) .reply(200, { access_token: 'token' }); nock('https://api.github.com/user') .get(/.*/) .reply(200, { login: 'astroash' }); request(app) .get('/auth?code=3aa491426dc2f4130a6b') .end((err, res) => { if (err) { console.log('error in getCookies: ', err); return; } cb(res.headers['set-cookie']); // }); }; ``` In test: ``` getCookies((cookies) => { request(app) .get('/must-be-logged-in-to-see-this-endpoint') .set('Cookie', cookies) .expect(200) .expect('Content-Type', /text\/html/) .end((err, res) => { t.same(res.statusCode, 200, 'Responds with 200'); t.error(err, 'No error'); t.end(); }); }); }); ``` ## Useful Resources * [Watch & Compile Your Sass with npm - Medium](https://medium.com/@brianhan/watch-compile-your-sass-with-npm-9ba2b878415b) * [Promise.all documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) * [Nock documentation](https://github.com/node-nock/nock) * [Request-Promise documentation](https://github.com/request/request-promise)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully