Code Monkey home page Code Monkey logo

web-core's Introduction

Web-Core

Reusable packages to make website building faster

Getting Started

Step 1:

Create a .npmrc file in the same directory as your package.json file and add this inside:

// .npmrc
registry=https://npm.pkg.github.com/farisaziz12

Step 2:

If you haven't already, configure npm for use with github packages .

Step 3:

run npm install @farisaziz12/web-core

Packages

Auth Package @farisaziz12/web-core/packages/auth/src

The Auth package is used for all authentication needs using firebase

const { Auth } = require("@farisaziz12/web-core/packages/auth/src");

// Config object for firebase initialization
const config = {
    apiKey: "firebaseApiKey",
};

/*
  For Authentication to work the Auth class instance needs to
  receive a config object with your firebase api key
*/

const auth = new Auth(config);

// LOGIN
auth.login(email, password)
    .then((userData) => console.log(userData))
    .catch((error) => console.error(error));

// The auth.login method returns a promise with the firebase user data

// GOOGLE LOGIN
auth.googleLogin() // No arguments needed as the user is redirected to a google login
    .then((userData) => console.log(userData))
    .catch((error) => console.error(error));

// The auth.googleLogin method returns a promise with the user data on successful redirect and login

// SIGN UP
auth.signUp(email, password, passwordConfirmation)
    .then((userData) => console.log(userData))
    .catch((error) => console.error(error));

/* The auth.signUp method returns a promise with the user data
  and sends a confirmation email using firebase
  if the password and password confirmation match
*/

// SIGN UP ERROR EXAMPLE
auth.signUp("[email protected]", "password", "pswrd")
    .then((userData) => console.log(userData))
    .catch((error) => console.error(error)); // => Error: Passwords do not match

/* If no password confirmation is provided or the passwords do not match
  an error is thrown and the user is not signed up
*/

// SIGN OUT
auth.signOut()
    .then((response) => console.log(response)) // response => { success: true }
    .catch((error) => console.error(error));

/* On successful firebase sign out the auth.signOut method returns a promise which
  resolves to a success object
*/

// GET CURRENT USER
auth.getCurrentUser()
    .then((currentUser) => console.log(currentUser)) // response => { email: "[email protected]", ... }
    .catch((error) => console.error(error));

/* If a user is currently logged in the auth.getCurrentUser method will return
  an object with the current user's data
*/

Contributing to Web-Core

Contributions are always welcome! Feel free to contribute towards any of the following:

  • Reporting a bug
  • Discussing the current state of the code
  • Submitting a fix
  • Proposing new features
  • Becoming a maintainer

This Project uses Github Flow, So All Code Changes Happen Through Pull Requests

Pull requests are the best way to propose changes to the codebase.

  1. Fork the repo and create your branch from develop.
  2. Make sure your commits follow the Conventional Commits standards.
  3. If you've added code that should be tested, add tests.
  4. If you've changed APIs, update the documentation.
  5. Ensure the test suite passes.
  6. Make sure your code lints.
  7. Issue that pull request!

Report bugs using Github's issues

GitHub is used issues to track bugs. Report a bug by opening a new issue; it's that easy!

Write bug reports with detail, background, and sample code:

Great Bug Reports tend to have:

  • A quick summary and/or background
  • Steps to reproduce
  • Be specific!
  • Give sample code if you can.
  • What you expected would happen
  • What actually happens
  • Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)

Use a Consistent Coding Style

  • 4 spaces for indentation
  • You can try running npm run format to get prettier to format your code.

Note:

Remeber to run npm run compile so that your Typescript code is compiled into Javascript and npm test to check if your code passes all old and new tests before you commit.

web-core's People

Contributors

farisaziz12 avatar

Watchers

 avatar  avatar

Forkers

meaningof42

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.