id
int64
0
3.46k
description
stringlengths
5
3.38k
readme
stringlengths
6
512k
0
LLVM-based compiler for the Nim language
# Introduction [nlvm](https://github.com/arnetheduck/nlvm) (the nim-level virtual machine?) is an [LLVM-based](http://llvm.org) compiler for the [Nim](http://nim-lang.org) language. From Nim's point of view, it's a backend just like C or JavaScript - from LLVM's point of view, it's a language frontend that emits IR. When I started on this little project, I knew neither llvm nor Nim. Therefore, I'd specially like to thank the friendly folks at the #nim channel that never seemed to tire of my nooby questions. Also, thanks to all tutorial writers out there, on llvm, programming and other topics for providing such fine sources of copy-pa... er, inspiration! Questions, patches, improvement suggestions and reviews welcome. When you find bugs, feel free to fix them as well :) Fork and enjoy! Jacek Sieka (arnetheduck on gmail point com) # Status `nlvm` is generally at par with `nim` in terms of features, with the following notable differences: * Fast compile times - no intermediate `C` compiler step * DWARF ("zero-cost") exception handling * High-quality `gdb`/`lldb` debug information with source stepping, type information etc * Smart code generation - compiler intrinsics for overflow checking, smart constant initialization, etc * Native `wasm32` support with no extra tooling Most things from `nim` work just fine (see notes below however!): * the same standard library is used * similar command line options are supported (just change `nim` to `nlvm`!) * `importc` works without needing `C` header files - the declaration in the `.nim` file needs to be accurate Test coverage is not too bad either: * bootstrapping and compiling itself * ~95% of all upstream tests - most failures can be traced to the standard library and compiler relying on C implementation details - see [skipped-tests.txt](skipped-tests.txt) for an updated list of issues * compiling most applications * platforms: linux/x86_64, wasm32 (pre-alpha!) * majority of the nim standard library (the rest can be fixed easily - requires upstream changes however) How you could contribute: * work on making [skipped-tests.txt](skipped-tests.txt) smaller * improve platform support (`osx` and `windows` should be easy, `arm` would be nice) * help `nlvm` generate better IR - optimizations, builtins, exception handling.. * help upstream make std library smaller and more `nlvm`-compatible * send me success stories :) * leave the computer for a bit and do something real for your fellow earthlings `nlvm` does _not_: * understand `C` - as a consequence, `header`, `emit` and similar pragmas will not work - neither will the fancy `importcpp`/`C++` features * support all nim compiler flags and features - do file bugs for anything useful that's missing # Compile instructions To do what I do, you will need: * Linux * A C/C++ compiler (ironically, I happen to use `gcc` most of the time) Start with a clone: cd $SRC git clone https://github.com/arnetheduck/nlvm.git cd nlvm && git submodule update --init We will need a few development libraries installed, mainly due to how `nlvm` processes library dependencies (see dynlib section below): # Fedora sudo dnf install pcre-devel openssl-devel sqlite-devel ninja-build cmake # Debian, ubuntu etc sudo apt-get install libpcre3-dev libssl-dev libsqlite3-dev ninja-build cmake Compile `nlvm` (if needed, this will also build `nim` and `llvm`): make Compile with itself and compare: make compare Run test suite: make test make stats You can link statically to LLVM to create a stand-alone binary - this will use a more optimized version of LLVM as well, but takes longer to build: make STATIC_LLVM=1 If you want a faster `nlvm`, you can also try the release build - it will be called `nlvmr`: make STATIC_LLVM=1 nlvmr When you update `nlvm` from `git`, don't forget the submodule: git pull && git submodule update To build a docker image, use: make docker To run built `nlvm` docker image use: docker run -v $(pwd):/code/ nlvm c -r /code/test.nim # Compiling your code On the command line, `nlvm` is mostly compatible with `nim`. When compiling, `nlvm` will generate a single `.o` file with all code from your project and link it using `$CC` - this helps it pick the right flags for linking with the C library. cd $SRC/nlvm/Nim/examples ../../nlvm/nlvm c fizzbuzz If you want to see the generated LLVM IR, use the `-c` option: cd $SRC/nlvm/Nim/examples ../../nlvm/nlvm c -c fizzbuzz less fizzbuzz.ll You can then run the LLVM optimizer on it: opt -Os fizzbuzz.ll | llvm-dis ... or compile it to assembly (`.s`): llc fizzbuzz.ll less fizzbuzz.s Apart from the code of your `.nim` files, the compiler will also mix in the compatibility found library in `nlvm-lib/`. ## Pipeline Generally, the `nim` compiler pipeline looks something like this: nim --> c files --> IR --> object files --> executable In `nlvm`, we remove one step and bunch all the code together: nim --> IR --> single object file --> executable Going straight to the IR means it's possible to express nim constructs more clearly, allowing `llvm` to understand the code better and thus do a better job at optimization. It also helps keep compile times down, because the `c-to-IR` step can be avoided. The practical effect of generating a single object file is similar to `gcc -fwhole-program -flto` - it is expensive in terms of memory, but results in slightly smaller and faster binaries. Notably, the `IR-to-machine-code` step, including any optimizations, is repeated in full for each recompile. ## Common issues ### dynlib `nim` uses a runtime dynamic library loading scheme to gain access to shared libraries. When compiling, no linking is done - instead, when running your application, `nim` will try to open anything the user has installed. `nlvm` does not support the `{.dynlib.}` pragma - instead you can use `{.passL.}` using normal system linking. ```nim # works with `nim` proc f() {. importc, dynlib: "mylib" .} # works with both `nim` and `nlvm` {.passL: "-lmylib".} proc f() {. importc .} ``` ### header and emit When `nim` compiles code, it will generate `c` code which may include other `c` code, from headers or directly via `emit` statements. This means `nim` has direct access do symbols declared in the `c` file, which can be both a feature and a problem. In `nlvm`, `{.header.}` directives are ignored - `nlvm` looks strictly at the signature of the declaration, meaning the declaration must _exactly_ match the `c` header file or subtly ABI issues and crashes ensue! ```nim # When `nim` encounters this, it will emit `jmp_buf` in the `c` code without # knowing the true size of the type, letting the `c` compiler determine it # instead. type C_JmpBuf {.importc: "jmp_buf", header: "<setjmp.h>".} = object # nlvm instead ignores the `header` directive completely and will use the # declaration as written. Failure to correctly declare the type will result # in crashes and subtle bugs - memory will be overwritten or fields will be # read from the wrong offsets. # # The following works with both `nim` and `nlvm`, but requires you to be # careful to match the binary size and layout exactly (note how `bycopy` # sometimes help to further nail down the ABI): when defined(linux) and defined(amd64): type C_JmpBuf {.importc: "jmp_buf", bycopy.} = object abi: array[200 div sizeof(clong), clong] # In `nim`, `C` constant defines are often imported using the following trick, # which makes `nim` emit the right `C` code that the value from the header # can be read (no writing of course, even though it's a `var`!) # # assuming a c header with: `#define RTLD_NOW 2` # works for nim: var RTLD_NOW* {.importc: "RTLD_NOW", header: "<dlfcn.h>".}: cint # both nlvm and nim (note how these values often can be platform-specific): when defined(linux) and defined(amd64): const RTLD_NOW* = cint(2) ``` ### wasm32 support `wasm32` support is still very bare-bones, so you will need to do a bit of tinkering to get it to work. Presently, the `wasm32-unknown-unknown` target is mapped to `--os:standalone` and `--cpu:wasm32` - this choice represents a very raw `wasm` engine with 32-bit little-endian integers and pointers - in the future, the `nim` standard library and `system.nim` will need to be updated to support WASM system interfaces like emscripten or WASI. To compile wasm files, you will thus need a `panicoverride.nim` - a minimal example looks like this and discards any errors: ```nim # panicoverride.nim proc rawoutput(s: string) = discard proc panic(s: string) {.noreturn.} = discard ``` After placing the above code in your project folder, you can compile `.nim` code to `wasm32`: ```nim # myfile.nim proc adder*(v: int): int {.exportc.} = v + 4 ``` ```sh nlvm c --cpu:wasm32 --os:standalone --gc:none --passl:--no-entry myfile.nim wasm2wat -l myfile.wasm ``` # Random notes * Upstream is pinned using a submodule - nlvm relies heavily on internals that keep changing - it's unlikely that it works with any other versions, patches welcome to update it * The nim standard library likes to import C headers directly which works because the upstream nim compiler uses a C compiler underneath - ergo, large parts of the standard library don't work with nlvm. * Happy to take patches for anything, including better platform support! * For development, it's convenient to build LLVM with assertions turned on - the API is pretty unforgiving
1
Nimbus: an Ethereum Execution Client for Resource-Restricted Devices
# Nimbus: ultra-light Ethereum execution layer client [![License: Apache](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) ![GH action-nimbus-eth1](https://github.com/status-im/nimbus-eth1/workflows/CI/badge.svg) ![GH action-fluffy](https://github.com/status-im/nimbus-eth1/workflows/fluffy%20CI/badge.svg) [![Discord: Nimbus](https://img.shields.io/badge/discord-nimbus-orange.svg)](https://discord.gg/XRxWahP) [![Status: #nimbus-general](https://img.shields.io/badge/status-nimbus--general-orange.svg)](https://get.status.im/chat/public/nimbus-general) ## Introduction This repository contains development work on an execution-layer client to pair with [our consensus-layer client](https://github.com/status-im/nimbus-eth2). This client focuses on efficiency and security and strives to be as light-weight as possible in terms of resources used. This repository is also home to: - [Fluffy](./fluffy/README.md), a [Portal Network](https://github.com/ethereum/stateless-ethereum-specs/blob/master/portal-network.md) light client. - [Nimbus Verified Proxy](./nimbus_verified_proxy/README.md) All consensus-layer client development is happening in parallel in the [nimbus-eth2](https://github.com/status-im/nimbus-eth2) repository. ## Development Updates Monthly development updates are shared [here](https://hackmd.io/jRpxY4WBQJ-hnsKaPDYqTw). Some recent highlights include: - Renewed funding from the EF to accelerate development - Completed Berlin and London fork compatibility (EIP-1559). It now passes nearly all the EF Hive testsuite, and 100% of contract execution tests (47,951 tests) - New GraphQL and WebSocket APIs, complementing JSON-RPC - EVMC compatibility, supporting third-party optimised EVM plugins - Up to 100x memory saving during contract executions - Asynchronous EVM to execute many contracts in parallel, while they wait for data from the network - Proof-of-authority validation for the Goerli test network - Updated network protocols, to work with the latest eth/65-66 and snap/1 protocols - A prototype new mechanism for state sync which combines what have been called Fast sync, Snap sync and Beam sync in a self-tuning way, and allows the user to participate in the network (read accounts, run transactions etc.) while sync is still in progress - A significant redesign of the storage database to use less disk space and run faster. For more detailed write-ups on the development progress, follow the [Nimbus blog](https://our.status.im/tag/nimbus/). ## Building & Testing ### Prerequisites * [RocksDB](https://github.com/facebook/rocksdb/) * GNU Make, Bash and the usual POSIX utilities. Git 2.9.4 or newer. On Windows, a precompiled DLL collection download is available through the `fetch-dlls` Makefile target: ([Windows instructions](#windows)). ```bash # MacOS with Homebrew brew install rocksdb # Fedora dnf install rocksdb-devel # Debian and Ubuntu sudo apt-get install librocksdb-dev # Arch (AUR) pakku -S rocksdb ``` `rocksdb` can also be installed by following [their instructions](https://github.com/facebook/rocksdb/blob/master/INSTALL.md). #### Obtaining the prerequisites through the Nix package manager *Experimental* Users of the [Nix package manager](https://nixos.org/nix/download.html) can install all prerequisites simply by running: ``` bash nix-shell default.nix ``` ### Build & Develop #### POSIX-compatible OS ```bash # The first `make` invocation will update all Git submodules. # You'll run `make update` after each `git pull`, in the future, to keep those submodules up to date. # Assuming you have 4 CPU cores available, you can ask Make to run 4 parallel jobs, with "-j4". make -j4 nimbus # See available command line options build/nimbus --help # Start syncing with mainnet build/nimbus # Update to latest version git pull make -j4 update # Run tests make test ``` To run a command that might use binaries from the Status Nim fork: ```bash ./env.sh bash # start a new interactive shell with the right env vars set which nim nim --version # or without starting a new interactive shell: ./env.sh which nim ./env.sh nim --version ``` Our Wiki provides additional helpful information for [debugging individual test cases][1] and for [pairing Nimbus with a locally running copy of Geth][2]. #### Windows _(Experimental support!)_ Install Mingw-w64 for your architecture using the "[MinGW-W64 Online Installer](https://sourceforge.net/projects/mingw-w64/files/)" (first link under the directory listing). Run it and select your architecture in the setup menu ("i686" on 32-bit, "x86\_64" on 64-bit), set the threads to "win32" and the exceptions to "dwarf" on 32-bit and "seh" on 64-bit. Change the installation directory to "C:\mingw-w64" and add it to your system PATH in "My Computer"/"This PC" -> Properties -> Advanced system settings -> Environment Variables -> Path -> Edit -> New -> C:\mingw-w64\mingw64\bin (it's "C:\mingw-w64\mingw32\bin" on 32-bit) Install [Git for Windows](https://gitforwindows.org/) and use a "Git Bash" shell to clone and build Nimbus. Install [cmake](https://cmake.org/). If you don't want to compile RocksDB and SQLite separately, you can fetch pre-compiled DLLs with: ```bash mingw32-make fetch-dlls # this will place the right DLLs for your architecture in the "build/" directory ``` You can now follow those instructions in the previous section by replacing `make` with `mingw32-make` (regardless of your 32-bit or 64-bit architecture): ```bash mingw32-make nimbus # build the Nimbus binary mingw32-make test # run the test suite # etc. ``` #### Raspberry PI *Experimental* The code can be compiled on a Raspberry PI: * Raspberry PI 3b+ * 64gb SD Card (less might work too, but the default recommended 4-8GB will probably be too small) * [Rasbian Buster Lite](https://www.raspberrypi.org/downloads/raspbian/) - Lite version is enough to get going and will save some disk space! Assuming you're working with a freshly written image: ```bash # Start by increasing swap size to 2gb: sudo vi /etc/dphys-swapfile # Set CONF_SWAPSIZE=2048 # :wq sudo reboot # Install prerequisites sudo apt-get install git libgflags-dev libsnappy-dev mkdir status cd status # Install rocksdb git clone https://github.com/facebook/rocksdb.git cd rocksdb make shared_lib sudo make install cd.. # Raspberry pi doesn't include /usr/local/lib in library search path - need to add export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH git clone https://github.com/status-im/nimbus.git cd nimbus # Follow instructions above! ``` #### Android *Experimental* Code can be compiled and run on Android devices ##### Environment setup * Install the [Termux](https://termux.com) app from FDroid or the Google Play store * Install a [PRoot](https://wiki.termux.com/wiki/PRoot) of your choice following the instructions for your preferred distribution. Note, the Ubuntu PRoot is known to contain all Nimbus prerequisites compiled on Arm64 architecture (common architecture for Android devices). Depending on the distribution, it may require effort beyond the scope of this guide to get all prerequisites. *Assuming Ubuntu PRoot is used* ```bash # Install prerequisites apt install librocksdb-dev # Clone repo and build Nimbus just like above git clone https://github.com/status-im/nimbus.git cd nimbus make make nimbus build/nimbus ``` ### <a name="make-xvars"></a>Experimental make variables Apart from standard Make flags (see link in the next [chapter](#devel-tips)), the following Make variables can be set to control which version of a virtual engine is compiled. The variables are listed with decreasing priority (in case of doubt, the lower prioritised variable is ignored when the higher on is available.) * ENABLE_CHUNKED_RLPX=0<br> Disable legacy chunked RLPx messages which are enabled by default for synchronising against `Nethermind` nodes * ENABLE_EVMC=1<br> Enable mostly EVMC compliant wrapper around the native Nim VM * ENABLE_VM2LOWMEM=1<br> Enable new re-factored version of the native Nim VM. This version is not optimised and coded in a way so that low memory compilers can handle it (observed on 32 bit windows 7.) * ENABLE_VM2=1<br> Enable new re-factored version of the native Nim VM. For these variables, using &lt;variable&gt;=0 is ignored and &lt;variable&gt;=2 has the same effect as &lt;variable&gt;=1 (ditto for other numbers.) ### <a name="devel-tips"></a>Development tips Interesting Make variables and targets are documented in the [nimbus-build-system](https://github.com/status-im/nimbus-build-system) repo. - you can switch the DB backend with a Nim compiler define: `-d:nimbus_db_backend=...` where the (case-insensitive) value is one of "rocksdb" (the default), "sqlite", "lmdb" - the Premix debugging tools are [documented separately](premix/readme.md) - you can control the Makefile's verbosity with the V variable (defaults to 0): ```bash make V=1 # verbose make V=2 test # even more verbose ``` - same for the [Chronicles log level](https://github.com/status-im/nim-chronicles#chronicles_log_level): ```bash make LOG_LEVEL=DEBUG nimbus # this is the default make LOG_LEVEL=TRACE nimbus # log everything ``` - pass arbitrary parameters to the Nim compiler: ```bash make NIMFLAGS="-d:release" ``` - if you want to use SSH keys with GitHub (also handles submodules): ```bash make github-ssh ``` - force a Nim compiler rebuild: ```bash rm vendor/Nim/bin/nim make -j8 build-nim ``` - some programs in the _tests_ subdirectory do a replay of blockchain database dumps when compiled and run locally. The dumps are found in [this](https://github.com/status-im/nimbus-eth1-blobs) module which need to be cloned as _nimbus-eth1-blobs_ parellel to the _nimbus-eth1_ file system root. #### Git submodule workflow Working on a dependency: ```bash cd vendor/nim-chronicles git checkout -b mybranch # make some changes git status git commit -a git push origin mybranch # create a GitHub PR and wait for it to be approved and merged git checkout master git pull git branch -d mybranch # realise that the merge was done without "--no-ff" git branch -D mybranch # update the submodule's commit in the superproject cd ../.. git status git add vendor/nim-chronicles git commit ``` It's important that you only update the submodule commit after it's available upstream. You might want to do this on a new branch of the superproject, so you can make a GitHub PR for it and see the CI test results. Don't update all Git submodules at once, just because you found the relevant Git command or `make` target. You risk updating submodules to other people's latest commits when they are not ready to be used in the superproject. Adding the submodule "https://github.com/status-im/foo" to "vendor/foo": ```bash vendor/nimbus-build-system/scripts/add_submodule.sh status-im/foo # or ./env.sh add_submodule status-im/foo # want to place it in "vendor/bar" instead? ./env.sh add_submodule status-im/foo vendor/bar ``` Removing the submodule "vendor/bar": ```bash git submodule deinit -f -- vendor/bar git rm -f vendor/bar ``` Checking out older commits, either to bisect something or to reproduce an older build: ```bash git checkout <commit hash here> make clean make -j8 update ``` Running a dependency's test suite using `nim` instead of `nimble` (which cannot be convinced not to run a dependency check, thus clashing with our jury-rigged "vendor/.nimble/pkgs"): ```bash cd vendor/nim-rocksdb ../nimbus-build-system/scripts/nimble.sh test # or ../../env.sh nimble test ``` ### Metric visualisation Install Prometheus and Grafana. On Gentoo, it's `emerge prometheus grafana-bin`. ```bash # build Nimbus make nimbus # the Prometheus daemon will create its data dir in the current dir, so give it its own directory mkdir ../my_metrics # copy the basic config file over there cp -a examples/prometheus.yml ../my_metrics/ # start Prometheus in a separate terminal cd ../my_metrics prometheus --config.file=prometheus.yml # loads ./prometheus.yml, writes metric data to ./data # start a fresh Nimbus sync and export metrics rm -rf ~/.cache/nimbus/db; ./build/nimbus --prune:archive --metricsServer ``` Start the Grafana server. On Gentoo it's `/etc/init.d/grafana start`. Go to http://localhost:3000, log in with admin:admin and change the password. Add Prometheus as a data source. The default address of http://localhost:9090 is OK, but Grafana 6.3.5 will not apply that semitransparent default you see in the form field, unless you click on it. Create a new dashboard. Click on its default title in the upper left corner ("New Dashboard"). In the new page, click "Import dashboard" in the right column and upload "examples/Nimbus-Grafana-dashboard.json". In the main panel, there's a hidden button used to assign metrics to the left or right Y-axis - it's the coloured line on the left of the metric name, in the graph legend. To see a single metric, click on its name in the legend. Click it again to go back to the combined view. To edit a panel, click on its title and select "Edit". [Obligatory screenshot.](https://i.imgur.com/AdtavDA.png) ### Troubleshooting Report any errors you encounter, please, if not [already documented](https://github.com/status-im/nimbus/issues)! * Turn it off and on again: ```bash make clean make update ``` ## License Licensed and distributed under either of * MIT license: [LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT or * Apache License, Version 2.0, ([LICENSE-APACHEv2](LICENSE-APACHEv2) or https://www.apache.org/licenses/LICENSE-2.0) at your option. These files may not be copied, modified, or distributed except according to those terms. [1]: https://github.com/status-im/nimbus/wiki/Understanding-and-debugging-Nimbus-EVM-JSON-tests [2]: https://github.com/status-im/nimbus/wiki/Debugging-state-reconstruction
2
A curated list of awesome Nim frameworks, libraries, software and resources.
<h1> <a href="https://nim-lang.org"><img src="asset/awesome-nim-logo.svg" alt="Awesome-nim-logo" width="600"/></a><a href="https://awesome.re"><img align="right" src="https://awesome.re/badge.svg"></a> </h1> > A curated list of awesome Nim frameworks, libraries, software and resources. [Nim](https://nim-lang.org/) is a statically typed compiled systems programming language. Good for everything from shell scripting to web front & backend, to ML, HPC, and embedded. <h2> Contents </h2> - [Language Features](#language-features) - [Implementations](#implementations) - [Standard Libraries](#standard-libraries) - [Package Repositories](#package-repositories) - [Editors](#editors) - [Async IO](#async-io) - [Threading](#threading) - [Error Handling](#error-handling) - [Contracts](#contracts) - [Object-Oriented Programming](#object-oriented-programming) - [Functional Programming](#functional-programming) - [Pattern Matching](#pattern-matching) - [Iteration](#iteration) - [Macros](#macros) - [Operating System](#operating-system) - [System API](#system-api) - [IO](#io) - [Processes](#processes) - [Date and Time](#date-and-time) - [Randomization](#randomization) - [Scripting](#scripting) - [Hardware](#hardware) - [Embedded](#embedded) - [Science](#science) - [Data](#data) - [Database](#database) - [Driver](#driver) - [ORM](#orm) - [Data Structures](#data-structures) - [Data Processing](#data-processing) - [Parsing](#parsing) - [Serialization](#serialization) - [Text](#text) - [String Types](#string-types) - [Translation](#translation) - [Markdown](#markdown) - [Multimedia](#multimedia) - [Audio](#audio) - [Images](#images) - [Documents](#documents) - [Algorithms](#algorithms) - [Math](#math) - [Symbolic](#symbolic) - [FFT](#fft) - [Vector](#vector) - [Matrix](#matrix) - [Deep Learning](#deep-learning) - [Bigints](#bigints) - [Cryptography](#cryptography) - [Blockchain](#blockchain) - [Compression](#compression) - [User Interface](#user-interface) - [Terminal](#terminal) - [Design](#design) - [GUI](#gui) - [Crossplatform](#crossplatform) - [Windows](#windows) - [Linux](#linux) - [Web Technology](#web-technology) - [Lightweight](#lightweight) - [Plotting](#plotting) - [Web](#web) - [Protocols](#protocols) - [DNS](#dns) - [QUIC](#quic) - [Websockets](#websockets) - [Messaging](#messaging) - [HTML Parsers](#html-parsers) - [HTTP Servers](#http-servers) - [Frameworks](#frameworks) - [Template Engines](#template-engines) - [Authentication](#authentication) - [Game Development](#game-development) - [Game Libraries](#game-libraries) - [Game Frameworks](#game-frameworks) - [Game Engines](#game-engines) - [Rules Engines](#rules-engines) - [Development Tools](#development-tools) - [Editor Integration](#editor-integration) - [REPL](#repl) - [Binding Generators](#binding-generators) - [Build Systems / Package Management](#build-systems--package-management) - [Logging](#logging) - [Testing](#testing) - [Fuzzing](#fuzzing) - [Benchmarking](#benchmarking) - [Command-Line Interface Automation](#command-line-interface-automation) - [Resources](#resources) - [Books](#books) - [Blogs](#blogs) - [Community](#community) - [Tutorials](#tutorials) - [Videos](#videos) ## Language Features ### Implementations - [Nim](https://github.com/nim-lang/Nim) - Nim (formerly known as "Nimrod") is a compiled, garbage-collected systems programming language which has an excellent productivity/performance ratio. Nim's design focuses on efficiency, expressiveness, elegance (in the order of priority). - [nlvm](https://github.com/arnetheduck/nlvm) - LLVM backend for Nim. ### Standard Libraries Nim provides unique features for seamless and transparent interoperability with other technologies. Some users found it useful to make other standard libraries usable from Nim. - [cpython](https://github.com/juancarlospaco/cpython) - Python standard library for Nim. - [Node.js](https://github.com/juancarlospaco/nodejs) - Node.js standard library for Nim. ### Package Repositories - [Nim packages](https://github.com/nim-lang/packages) - List of packages for Nimble. - [Nim package directory](https://nimble.directory/) - Explore Nim packages known to Nimble. ### Editors - [moe](https://github.com/fox0430/moe) - A vim-like editor made with Nim, also supports C, Rust, Javascript, etc. - [Nim Playground](https://play.nim-lang.org/) - Code and run Nim online. - [DoongJohn's Nim playground](https://doongjohn.github.io/nim-playground/) - An alternative implementation of the Nim playground. ### Async IO - [std/async](https://nim-lang.org/docs/async.html) - Async/await implementation in Nim's stdlib (aka asyncdispatch). - [chronos](https://github.com/status-im/nim-chronos) - An efficient library for asynchronous programming. - [cps](https://github.com/disruptek/cps) - Continuation-Passing Style for Nim. ### Threading - [weave](https://github.com/mratsim/weave) - A state-of-the-art multithreading runtime: message-passing based, fast, scalable, ultra-low overhead. - [timerpool](https://github.com/mikra01/timerpool) - Threadsafe timerpool implementation for event purposes. - [taskpools](https://github.com/status-im/nim-taskpools) - Lightweight, energy-efficient, easily auditable threadpools. - [shared](https://github.com/genotrance/shared) - A Nim library for shared types. - [synthesis](https://github.com/mratsim/Synthesis) - A compiletime, procedure-based, low-overhead, no-allocation, state-machine generator optimized for communicating processes and threads. - [sync](https://github.com/planetis-m/sync) - Useful synchronization primitives. ### Error Handling - [result](https://github.com/arnetheduck/nim-result/) - Friendly, exception-free value-or-error returns, similar to Option[T]. - [questionable](https://github.com/status-im/questionable) - Elegant optional types for Nim. - [optionsutils](https://github.com/PMunch/nim-optionsutils) - Utility macros for easier handling of options in Nim. ### Contracts - [contracts](https://github.com/Udiknedormin/NimContracts) - Used to make contracts - elegant promises that pieces of code will fulfill certain conditions. - [contra](https://github.com/juancarlospaco/nim-contra) - Lightweight and fast self-documenting design by contract programming. ### Object-Oriented Programming - [oop_utils](https://github.com/bluenote10/oop_utils) - Nim macros for building OOP class hierarchies. - [interfaced](https://github.com/andreaferretti/interfaced) - Interfaces for Nim. - [traitor](https://github.com/beef331/traitor) - A macro heavy trait library made from boredom. - [classy](https://github.com/nigredo-tori/classy) - Haskell-style typeclasses for Nim. ### Functional Programming - [cascade](https://github.com/citycide/cascade) - Method & assignment cascades for Nim, inspired by Smalltalk & Dart. - [nimfp](https://github.com/vegansk/nimfp) - Nim functional programming library. - [nim-pipexp](https://github.com/ShalokShalom/nim-pipexp) - Expression-based pipe operators with placeholder argument for Nim. - [pipe](https://github.com/5paceToast/pipe) - Pipe operator for Nim, as seen in functional languages. - [zero-functional](https://github.com/zero-functional/zero-functional) - A library providing (almost) zero-cost chaining for functional abstractions in Nim. ### Pattern Matching - [regex](https://github.com/nitely/nim-regex) - Pure Nim regex engine with linear time match. - [npeg](https://github.com/zevv/npeg) - PEGs for Nim, another take. - [patty](https://github.com/andreaferretti/patty) - A pattern matching library for Nim. - [gara](https://github.com/alehander42/gara) - Macro-based pattern matching library. - [glob](https://github.com/citycide/glob) - Pure library for matching file paths against Unix style glob patterns. - [ast_pattern_match](https://github.com/krux02/ast-pattern-matching) - A library to do pattern matching on the AST. - [awk](https://github.com/greencardamom/awk) - A library of awk functions in Nim. ### Iteration - [iterrr](https://github.com/hamidb80/iterrr) - Macros-based functional-style, lazy-like, extensible iterator library. - [itertools](https://github.com/narimiran/itertools) - Nim rewrite of a very popular Python module of the same name. - [loopfusion](https://github.com/numforge/loopfusion) - Iterate efficiently over a variadic number of containers. - [looper](https://github.com/b3liever/looper) - For loop macros for Nim. - [mangle](https://github.com/baabelfish/mangle) - Attempt at a streaming library. ### Macros - [macroutils](https://github.com/PMunch/macroutils) - A package that makes creating macros easier. - [nimacros](https://github.com/FemtoEmacs/nimacros) - Documentation for Nim macros. - [unpack](https://github.com/technicallyagd/unpack) - Sequence/object unpacking/destructuring. - [with](https://github.com/zevv/with) - The `with` macro for Nim. - [memo](https://github.com/andreaferretti/memo) - Memoization for Nim. ## Operating System ### System API - [winim](https://github.com/khchen/winim) - Nim's Windows API and COM Library. - [serial](https://github.com/euantorano/serial.nim) - A Nim library for accessing serial ports. - [tempdir](https://github.com/euantorano/tempdir.nim) - A Nim library to create and manage temporary directories. - [nimbluez](https://github.com/Electric-Blue/NimBluez) - Nim modules for access to system Bluetooth resources. ### IO - [std/selectors](https://nim-lang.org/docs/selectors.html) - Epoll/Kqueue/Select implementation in Nim's stdlib. - [ioselectors](https://github.com/xflywind/ioselectors) - The ioselectors plus for Nim. - [wepoll](https://github.com/xflywind/wepoll) - Windows epoll wrapper for Nim. - [faststreams](https://github.com/status-im/nim-faststreams) - Nearly zero-overhead input/output streams for Nim. - [lockfreequeues](https://github.com/elijahr/lockfreequeues) - Lock-free queue implementations for Nim. ### Processes - [psutil](https://github.com/johnscillieri/psutil-nim) - A port of Python's psutil to Nim. - [shell](https://github.com/Vindaar/shell) - A mini Nim DSL to execute shell commands more conveniently. - [schedules](https://github.com/soasme/nim-schedules) - A Nim scheduler library that lets you kick off jobs at regular intervals. - [daemon](https://github.com/status-im/nim-daemon) - Cross-platform process daemonization library for the Nim language. ### Date and Time - [datetime2human](https://github.com/juancarlospaco/nim-datetime2human) - Calculate date & time with precision from seconds to millenniums. Human friendly date time as string. ISO-8601. - [timezones](https://github.com/GULPF/timezones) - Nim timezone library compatible with the standard library. - [chrono](https://github.com/treeform/chrono) - A timestamps, calendars, and timezones library. ### Randomization - [random](https://github.com/oprypin/nim-random) - Random number generation library for Nim, inspired by Python's "random" module. - [sysrandom.nim](https://github.com/euantorano/sysrandom.nim) - A Nim library to generate random numbers and random ranges of bytes using the system's PRNG. - [alea](https://github.com/andreaferretti/alea) - Define and compose random variables. - [drand48](https://github.com/JeffersonLab/drand48) - Nim implementation of the standard Unix drand48 random number generator. ### Scripting - [nimcr](https://github.com/PMunch/nimcr) - Running Nim code with Shebangs. - [nimr](https://github.com/Jeff-Ciesielski/nimr) - Run Nim programs like scripts. ## Hardware - [nimvisa](https://github.com/leeooox/nimvisa) - Wrapper for NI-VISA instrument control library. - [ftd2xx](https://github.com/leeooox/ftd2xx) - Wrapper for FTDI ftd2xx library (USB to JTAG/SPI/I2C/Bitbang etc.). ### Embedded - [ratel](https://github.com/PMunch/ratel) - Next-generation, zero-cost abstraction microconroller programming in Nim. - [ardunimo](https://github.com/gokr/ardunimo) - Nim wrapper for Arduino + LinkIt ONE SDK by Mediatek. - [ardunimesp](https://gitlab.com/NetaLabTek/Arduimesp) - Nim wrapper for Arduino ESP8266 framework + A tool for flashing, compiling and making a Nim project into an Arduino project. - [msp430f5510](https://gitlab.com/jalexander8717/msp430f5510-nim) - Run Nim on MSP430f5510 micro-controller (6KB of RAM). - [Nesper](https://github.com/elcritch/nesper) - Program the ESP32 using Nim. Library on top of esp-idf. - [stm32f3](https://github.com/mwbrown/nim_stm32f3) - Run Nim on STM32F3 micro-controller (16KB of RAM). - [boneIO](https://github.com/xyz32/boneIO) - GPIO implementation for the BeagleBone Black for Nim. ## Science - [units](https://github.com/Udiknedormin/NimUnits) - Statically-typed quantity units library for the Nim language. - [unchained](https://github.com/SciNim/Unchained) - A fully type safe, compile time only units library. - [metric](https://github.com/mjendrusch/metric) - A small library providing type-level dimensional analysis. - [orbits](https://github.com/treeform/orbits) - Orbital mechanics library for Nim. ## Data ### Database #### Driver - [nimongo](https://github.com/SSPkrolik/nimongo) - Pure Nim lang MongoDB driver. - [asyncpg](https://github.com/cheatfate/asyncpg) - Asynchronous PostgreSQL driver for Nim. - [anonimongo](https://github.com/mashingan/anonimongo) - Another Nim pure Mongo DB driver. - [redis](https://github.com/nim-lang/redis) - Official redis wrapper for Nim. - [amysql](https://github.com/bung87/amysql) - Async MySQL Connector write in pure Nim. - [mycouch](https://github.com/hamidb80/mycouch) - Multisync CouchDB driver for Nim. - [SQLiteral](https://github.com/olliNiinivaara/SQLiteral) - A high level SQLite API for Nim. - [asyncmysql](https://github.com/tulayang/asyncmysql) - Asynchronous MySQL connector written in pure Nim. - [sqlcipher](https://github.com/status-im/nim-sqlcipher) - SQLCipher wrapper. - [litestore](https://github.com/h3rald/litestore) - A lightweight, self-contained, RESTful, searchable, multi-format NoSQL document store. - [rocksdb](https://github.com/status-im/nim-rocksdb) - Nim wrapper for RocksDB, a persistent key-value store for flash and RAM Storage. #### ORM - [ormin](https://github.com/Araq/ormin) - Prepared SQL statement generator , A lightweight ORM. - [allographer](https://github.com/itsumura-h/nim-allographer) - A query_builder/ORM library inspired by Laravel/PHP and Orator/Python for Nim. - [gatabase](https://github.com/juancarlospaco/nim-gatabase) - Connection-Pooling Compile-Time ORM for Nim. - [norm](https://github.com/moigagoo/norm) - Norm is an object-oriented, framework-agnostic ORM for Nim that supports SQLite and PostgreSQL. ### Data Structures - [BitVector](https://github.com/MarcAzar/BitVector) - A high-performance Nim implementation of BitVectors. - [rbtree](https://github.com/Nycto/RBTreeNim) - A Red/Black tree implementation in Nim. - [quadtree](https://github.com/Nycto/QuadtreeNim) - A Quadtree library for Nim. - [kdtree](https://github.com/jblindsay/kdtree) - A pure Nim k-d tree implementation for efficient spatial querying of point data. - [RTree](https://github.com/StefanSalewski/RTree) - Generic R-tree implementation for Nim. - [sorta](https://github.com/narimiran/sorta) - SortedTables in Nim, based on B-trees. - [minmaxheap](https://github.com/StefanSalewski/minmaxheap) - A Nim implementation of a Minimum-Maximum heap. - [BipBuffer](https://github.com/MarcAzar/BipBuffer) - A Nim implementation of Simon Cooke's Bib Buffer - [bloom](https://github.com/boydgreenfield/nimrod-bloom) - Bloom filter implementation in Nim. - [binaryheap](https://github.com/bluenote10/nim-heap) - Simple binary heap implementation in Nim. - [faststack](https://github.com/Vladar4/FastStack) - Dynamically resizable data structure for fast iteration over large arrays of similar elements. - [StashTable](https://github.com/olliNiinivaara/StashTable) - Concurrent hash tables for Nim. ### Data Processing - [NimData](https://github.com/bluenote10/NimData) - DataFrame API written in Nim, enabling fast out-of-core data processing. - [Datamancer](https://github.com/SciNim/Datamancer) - A dataframe library with a dplyr like API. - [nimdataframe](https://github.com/qqtop/nimdataframe) - Dataframe for Nim. - [nimhdf5](https://github.com/Vindaar/nimhdf5) - Wrapper and some simple high-level bindings for the HDF5 library for Nim. - [mpfit](https://github.com/Vindaar/nim-mpfit) - A wrapper for the cMPFIT library for Nim. ### Parsing - [parsetoml](https://github.com/NimParsers/parsetoml) - A Nim library to parse TOML files. - [NimYAML](https://github.com/flyx/NimYAML) - YAML implementation for Nim. - [Binarylang](https://github.com/sealmove/binarylang) - Extensible Nim DSL for creating binary parsers/encoders in a symmetric fashion. ### Serialization - [serialization](https://github.com/status-im/nim-serialization) - A modern and extensible serialization framework for Nim. - [json-serialization](https://github.com/status-im/nim-json-serialization) - Flexible JSON serialization not relying on run-time type information. - [protobuf-serialization](https://github.com/status-im/nim-protobuf-serialization) - The nim-protobuf-serialization. - [ssz-serialization](https://github.com/status-im/nim-ssz-serialization) - Nim implementation of Simple Serialize (SSZ) serialization and merkleization. - [toml-serialization](https://github.com/status-im/nim-toml-serialization) - Flexible TOML serialization `not` relying on run-time type information. - [frosty](https://github.com/disruptek/frosty) - Marshal native Nim objects via streams, sockets. - [protobuf-nim](https://github.com/PMunch/protobuf-nim) - Protobuf implementation in pure Nim that leverages the power of the macro system to not depend on any external tools. - [flatty](https://github.com/treeform/flatty) - Tools and serializer for plain flat binary files. - [nesm](https://xomachine.gitlab.io/NESM/) - NESM is a tool that generates serialization and deserialization code for a given object. - [bingo](https://github.com/planetis-m/bingo) - Binary serialization framework for Nim. ## Text ### String Types - [ssostrings](https://github.com/planetis-m/ssostrings) - Small String Optimized (SSO) string implementation. - [cowstrings](https://github.com/planetis-m/cowstrings) - Copy-On-Write string implementation according to nim-lang/RFCs#221. ### Translation - [tinyslation](https://github.com/juancarlospaco/nim-tinyslation) - Text string translation from free online crowdsourced API. ### Markdown - [HastyScribe](https://github.com/h3rald/hastyscribe) - Self-contained markdown compiler generating self-contained HTML documents. - [markdown](https://github.com/soasme/nim-markdown) - A beautiful Markdown Parser in the Nim world. - [lester](https://github.com/madprops/lester) - Create quick documents out of Markdown, into HTML. ## Multimedia ### Audio - [paramidi](https://github.com/paranim/paramidi) - A Nim library for making MIDI music. - [omni](https://github.com/vitreo12/omni) - A DSL for low-level audio programming. - [wave](https://github.com/jiro4989/wave) - A tiny WAV sound module. - [parasound](https://github.com/paranim/parasound) - A library to provide Nim bindings for miniaudio and dr_wav. ### Images - [pixie](https://github.com/treeform/pixie) - A full-featured 2D graphics library for Nim. - [nimpng](https://github.com/jangko/nimPNG) - PNG (Portable Network Graphics) decoder and encoder written in Nim. - [nimbmp](https://github.com/jangko/nimBMP) - BMP decoder and encoder written in Nim. - [nimsvg](https://github.com/bluenote10/NimSvg) - A Nim-based DSL allowing generation of SVG files and GIF animations. - [pnm](https://github.com/jiro4989/pnm) - Library for PNM (Portable Anymap) in Nim. ### Documents - [nimpdf](https://github.com/jangko/nimpdf) - PDF document writer, written in Nim. ## Algorithms ### Math #### Symbolic - [symbolicnim](https://github.com/HugoGranstrom/symbolicnim) - A symbolic library written purely in Nim. #### FFT - [impulse](https://github.com/SciNim/impulse) - Impulse will be a collection of primitives for signal processing (FFT, Convolutions). #### Vector - [vectorize](https://github.com/SciNim/vectorize) - SIMD vectorization backend. - [vmath](https://github.com/treeform/vmath) - Math vector library for graphical things. #### Matrix - [neo](https://github.com/unicredit/neo) - A matrix library. - [manu](https://github.com/planetis-m/manu) - Nim MAtrix NUmeric package - a port of JAMA, adapted to Nim. - [nlopt](https://github.com/Vindaar/nimnlopt) - A wrapper for the nonlinear optimization library Nlopt. ### Deep Learning - [Arraymancer](https://github.com/mratsim/Arraymancer) - A fast, ergonomic and portable tensor library in Nim with a deep learning focus for CPU, GPU, OpenCL and embedded devices. - [NimTorch](https://github.com/sinkingsugar/nimtorch) - PyTorch - Python + Nim. A Nim front-end to PyTorch's native backend, combining Nim's speed, productivity and portability with PyTorch's latest implementations. - [laser](https://github.com/numforge/laser) - Carefully-tuned primitives for running tensor and image-processing code on CPU, GPUs and accelerators. <!-- - [flambeau](https://github.com/SciNim/flambeau) - Nim bindings to libtorch. --> ### Bigints - [bigints](https://github.com/nim-lang/bigints) - Bigints for Nim. - [stint](https://github.com/status-im/nim-stint) - Stack-based arbitrary-precision integers. Fast and portable with natural syntax for resource-restricted devices. - [theo](https://github.com/SciNim/theo) - An optimized bigint and number theory library for Nim. ### Cryptography - [nimcrypto](https://github.com/cheatfate/nimcrypto) - Nim cryptographic library. - [nimaes](https://github.com/jangko/nimAES) - Advanced Encryption Standard, Rinjdael Algorithm written in Nim. - [constantine](https://github.com/mratsim/constantine) - Constant time pairing-based of elliptic curve based cryptography and digital signatures. - [bslcurve](https://github.com/status-im/nim-blscurve) - Nim implementation of BLS signature scheme (Boneh-Lynn-Shacham) over Barreto-Lynn-Scott (BLS) curve BLS12-381. - [bncurve](https://github.com/status-im/nim-bncurve) - Nim implementation of Barreto-Naehrig pairing-friendly elliptic curve. - [xxtea](https://github.com/xxtea/xxtea-nim) - XXTEA encryption algorithm library. - [crc32](https://github.com/juancarlospaco/nim-crc32) - CRC32 for Nim. Just pass the thing you want to do CRC. - [rollinghash](https://github.com/MarcAzar/RollingHash) - High performance Nim implementation of a Cyclic Polynomial Hash, aka BuzHash, and the Rabin-Karp algorithm. - [murmurhash](https://github.com/cwpearson/nim-murmurhash) - Pure Nim implementation of MurmerHash - [des](https://github.com/LucaWolf/des.nim) - DES/3DES, DUKPT and MAC in Nim. - [shimsham](https://github.com/apense/shimsham) - A collection of hash functions, including JH, SHA-2, SHA-3, SipHash, Tiger, and Whirlpool. - [NiMPC](https://github.com/markspanbroek/nimpc) - A secure multi-party computation (MPC) library for the Nim programming language. ### Blockchain - [eth](https://github.com/status-im/nim-eth) - Common utilities for Ethereum. - [nimbus-eth1](https://github.com/status-im/nimbus-eth1) - An Ethereum 1.0 and 2.0 client for resource-restricted devices. - [nimbus-eth2](https://github.com/status-im/nimbus-eth2) - Efficient implementation of the Ethereum 2.0 blockchain. - [evmc](https://github.com/status-im/nim-evmc) - Ethereum VM binary compatible interface. - [ethash](https://github.com/status-im/nim-ethash) - A pure-Nim implementation of Ethash, the Ethereum proof of work. - [contract-abi](https://github.com/status-im/nim-contract-abi) - Implements encoding of parameters according to the Ethereum Contract ABI specification. <!-- - [web3](https://github.com/status-im/nim-web3) - The humble beginnings of a Nim library similar to web3.[js|py]. --> <!-- - [abc](https://github.com/status-im/nim-abc) - Experimental asynchronous blockchain. --> <!-- - [nitro](https://github.com/status-im/nim-nitro) - Highly experimental implementation of the Nitro statechannels protocol in Nim. --> ### Compression - [zippy](https://github.com/guzba/zippy) - Pure Nim implementation of deflate, zlib, gzip and zip. - [supersnappy](https://github.com/guzba/supersnappy) - Dependency-free and performant Nim Snappy implementation. - [snappy](https://github.com/status-im/nim-snappy) - Nim implementation of Snappy compression algorithm. - [zip](https://github.com/nim-lang/zip) - Wrapper for the zip library. ## User Interface ### Terminal - [illwill](https://github.com/johnnovak/illwill) - Simple cross-platform terminal library inspired by (n)curses. - [NimCx](https://github.com/qqtop/NimCx) - Color and utilities for the Linux terminal. - [pager](https://git.sr.ht/~reesmichael1/nim-pager) - A simple command line pager library, written in Nim. ### Design - [chroma](https://github.com/treeform/chroma) - Everything you want to do with colors, in Nim. - [typography](https://github.com/treeform/typography) - Fonts, typesetting and rasterization. - [trick](https://github.com/exelotl/trick) - Library for GBA/NDS image conversion, and more! ### GUI #### Crossplatform - [nimx](https://github.com/yglukhov/nimx) - Desktop, Mobile & Web GUI framework in Nim. - [NiGui](https://github.com/trustable-code/NiGui) - A cross-platform, desktop GUI toolkit. - [ui](https://github.com/nim-lang/ui) - Wrapper for libui. Beginnings of what might become Nim's official UI library. - [iup](https://github.com/nim-lang/iup) - Wrapper for IUP. Beginnings of what might become Nim's official UI library. - [SDL2](https://github.com/nim-lang/sdl2) - Official wrapper for SDL 2.x. - [SDL2](https://github.com/Vladar4/sdl2_nim) - A wrapper for SDL 2. #### Windows - [wNim](https://github.com/khchen/wNim) - Nim's Windows GUI Framework. #### Linux - [gintro](https://github.com/StefanSalewski/gintro) - High-level GObject-Introspection based GTK3/GTK4 bindings for Nim. - [nimqml](https://github.com/filcuc/nimqml) - Qt QML bindings for the Nim programming language. #### Web Technology - [Neel](https://github.com/Niminem/Neel) - A library for making Electron-like HTML/JS GUI apps. - [nimview](https://github.com/marcomq/nimview) - A Nim/Webview based helper to create desktop/server applications with Nim and HTML/CSS. - [webgui](https://github.com/juancarlospaco/webgui) - Web technologies based cross-platform GUI Framework with a dark theme. - [fidget](https://github.com/treeform/fidget) - Figma based UI library for Nim, with HTML and OpenGL backends. - [nsciter](https://github.com/Yardanico/nsciter) - High-level and low-level Nim wrapper for https://sciter.com. #### Lightweight - [imgui](https://github.com/nimgl/imgui) - ImGui bindings for Nim via cimgui. - [nimAntTweakBar](https://github.com/krux02/nimAntTweakBar) - Wrapper for AntTweakBar. ### Plotting - [ggplotnim](https://github.com/Vindaar/ggplotnim) - A port of ggplot2 for Nim. - [plotly](https://github.com/SciNim/nim-plotly) - A plotly wrapper for Nim. - [graph](https://github.com/stisa/graph) - A basic plotting library in Nim. - [nimetry](https://github.com/refaqtor/nimetry) - Simple plotting in pure Nim. - [nimgraphviz](https://github.com/Aveheuzed/nimgraphviz) - A Nim library for making graphs with GraphViz and DOT. ## Web ### Protocols - [http-utils](https://github.com/status-im/nim-http-utils) - HTTP helper procedures. - [puppy](https://github.com/treeform/puppy) - Puppy fetches HTML pages for Nim. - [netty](https://github.com/treeform/netty) - Reliable UDP connection library for games in Nim. - [json-rpc](https://github.com/status-im/nim-json-rpc) - Nim library for implementing JSON-RPC clients and servers. - [nmqtt](https://github.com/zevv/nmqtt) - Native Nim MQTT client library. - [libp2p](https://github.com/status-im/nim-libp2p) - A Nim implementation of the libp2p networking stack. - [libp2p-dht](https://github.com/status-im/nim-libp2p-dht) - DHT based on the libp2p kademlia spec. - [webdavclient](https://github.com/beshrkayali/webdavclient) - WebDAV client for Nim. - [stomp](https://github.com/subsetpark/nim-stomp) - A pure-Nim client library for interacting with Stomp compliant message brokers. - [presto](https://github.com/status-im/nim-presto) - An efficient REST API framework. #### DNS - [ndns](https://github.com/rockcavera/nim-ndns) - A pure Nim Domain Name System (DNS) client. - [dnsprotocol](https://github.com/rockcavera/nim-dnsprotocol) - Domain Name System (DNS) protocol for Nim programming language. #### QUIC - [quic](https://github.com/status-im/nim-quic) - QUIC for Nim. This is very much a work in progress, and not yet in a usable state. - [ngtcp2](https://github.com/status-im/nim-ngtcp2) - A wrapper around ngtcp2: an effort to implement IETF QUIC protocol. #### Websockets - [ws](https://github.com/treeform/ws) - Simple WebSocket library for Nim. - [websocket.nim](https://github.com/niv/websocket.nim) - WebSockets for Nim. - [news](https://github.com/Tormund/news) - Nim Easy WebSocket. Based on ws. - [jswebsockets](https://juancarlospaco.github.io/nodejs/nodejs/jswebsockets) - WebSockets optimized for JavaScript targets. - [websock](https://github.com/status-im/nim-websock) - An implementation of the WebSocket protocol for Nim. #### Messaging - [telebot.nim](https://github.com/ba0f3/telebot.nim) - Async client for Telegram Bot API in pure Nim. - [dimscord](https://github.com/krisppurg/dimscord) - A Discord Bot & REST Library for Nim. - [nwaku](https://github.com/status-im/nwaku) - Implementation of the Waku v1 and v2 protocols. - [status](https://github.com/status-im/nim-status) - Nim implementation of the Status protocol. ### HTML Parsers - [Nimquery](https://github.com/GULPF/nimquery) - Library for querying HTML using CSS selectors, like JavaScript's `document.querySelector`. ### HTTP Servers - [httpbeast](https://github.com/dom96/httpbeast) - A highly performant, multi-threaded HTTP 1.1 server ([top 10 in FrameworkBenchmarks](https://www.techempower.com/benchmarks/#section=data-r18&test=json)). - [httpx](https://github.com/ringabout/httpx) - Cross platform web server for Nim. A fork of httpbeast adding Windows support. - [GuildenStern](https://github.com/olliNiinivaara/GuildenStern) - Genuinely multithreading integrated HTTP/1.1 + WebSocket v13 Server for POSIX-compliant OSes. - [Mummy](https://github.com/guzba/mummy) - A multi-threaded HTTP 1.1 server with first-class support for WebSockets. - [netkit](https://github.com/iocrate/netkit) - Out-of-the-box, stable and secure network facilities and utilities written in pure Nim. - [jshttp2](https://juancarlospaco.github.io/nodejs/nodejs/jshttp2) - Async HTTPS 2.0 web server. ### Frameworks - [Jester](https://github.com/dom96/jester) - The sinatra-like web framework for Nim. Jester provides a DSL for quickly creating web applications in Nim. - [prologue](https://github.com/planety/prologue) - A fullstack web framework written in Nim. - [whip](https://github.com/mattaylor/whip) - Simple and fast HTTP server for Nim based on httpbeast and nest for high performance routing. - [basolato](https://github.com/itsumura-h/nim-basolato) - A fullstack web framework for Nim based on Jester. - [karax](https://github.com/karaxnim/karax) - A framework for developing single page applications in Nim. - [akane](https://github.com/Ethosa/akane) - An asynchronous web framework. - [scorper](https://github.com/bung87/scorper) - A micro and elegant web framework written in Nim. - [starlight](https://github.com/planety/starlight) - Flask-like web framework written in Nim. - [rosencrantz](https://github.com/andreaferretti/rosencrantz) - DSL to write web servers, inspired by Spray and its successor Akka HTTP. - [nim_websitecreator](https://github.com/ThomasTJdev/nim_websitecreator) - Nim fullstack website framework - deploy a website within minutes. ### Template Engines - [smalte](https://github.com/roquie/smalte) - It is a dead simple and lightweight template engine. Specially designed for configure application before start in Docker. - [html-dsl](https://github.com/juancarlospaco/nim-html-dsl) - Nim HTML DSL. - [templates](https://github.com/onionhammer/nim-templates) - A simple string templating library for Nim. - [nimja](https://github.com/enthus1ast/nimja) - Typed and compiled template engine inspired by jinja2, twig and onionhammer/nim-templates for Nim. - [mustache](https://github.com/soasme/nim-mustache) - A full implementation of v1.2.1 of the Mustache spec. ### Authentication - [httpauth](https://github.com/FedericoCeratto/nim-httpauth) - HTTP Authentication library for Nim. - [oauth](https://github.com/CORDEA/oauth) - OAuth library for Nim. ## Game Development ### Game Libraries - [nimgl](https://github.com/nimgl/nimgl) - NimGL is a Nim library that offers bindings for popular libraries used in computer graphics. - [glm](https://github.com/stavenko/nim-glm) - Port of the popular glm C++ library to Nim. - [GLAD](https://github.com/Dav1dde/glad) - Multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specs. - [enu](https://github.com/dsrw/enu) - 3D live coding with a Logo-like DSL for Godot, implemented in Nim. ### Game Frameworks - [nico](https://github.com/ftsf/nico) - Nim Game Framework based on Pico-8. - [natu](https://github.com/exelotl/natu) - Toolkit for writing Game Boy Advance games in Nim. - [naylib](https://github.com/planetis-m/naylib) - safe Raylib wrapper. - [c4](https://github.com/c0ntribut0r/cat-400) - Modular and extensible 2D and 3D game framework for Nim. - [paranim](https://github.com/paranim/paranim) - A game library based around carefully chosen abstractions. ### Game Engines - [NimForUE](https://github.com/jmgomez/NimForUE) - Nim plugin for UE5 with native performance, hot reloading and full interop that sits between C++ and Blueprints. - [nimgame2](https://github.com/Vladar4/nimgame2) - A simple 2D game engine for Nim. - [norx](https://github.com/tankfeud/norx) - A complete wrapper of the ORX 2.5D cross platform game engine library. - [godot-nim](https://github.com/pragmagic/godot-nim) - Nim bindings for Godot Engine. - [rod](https://github.com/yglukhov/rod) - Cross-platform 2D and 3D game engine. - [frag](https://github.com/Tail-Wag-Games/frag) - Cross-platform 2D/3D game engine. ### Rules Engines - [turn_based_game](https://github.com/JohnAD/turn_based_game) - A game rules engine for simulating or playing turn-based games. - [pararules](https://github.com/paranim/pararules) - A RETE-based rules engine made for games. ## Development Tools ### Editor Integration - [Editor Support](https://github.com/nim-lang/Nim/wiki/editor-support) - Official list of editor plugins for Nim. - [nimlsp](https://github.com/PMunch/nimlsp) - The Language Server Protocol implementation for Nim. - [nim.nvim](https://github.com/alaviss/nim.nvim) - Nim plugin for NeoVim. - [vscode-nim](https://github.com/saem/vscode-nim) - Language support for the Nim programming language for VS Code. ### REPL - [INim](https://github.com/AndreiRegiani/INim) - Interactive Nim Shell. - [jupyternim](https://github.com/stisa/jupyternim) - A Jupyter kernel for Nim. ### Binding Generators - [c2nim](https://github.com/nim-lang/c2nim) - c2nim is a tool to translate Ansi C code to Nim. - [nimgen](https://github.com/genotrance/nimgen) - nimgen is a helper for c2nim to simplify and automate the wrapping of C libraries. Superseded by nimterop. - [nimterop](https://github.com/nimterop/nimterop) - A Nim package that leverages tree-sitter to make C/C++ interop seamless. Superseded by Futhark. - [Futhark](https://github.com/PMunch/futhark) - Automatic wrapping of C headers in Nim with libclang. - [nimpy](https://github.com/yglukhov/nimpy) - Generate Python wrappers and call Python from Nim. - [jnim](https://github.com/yglukhov/jnim) - Nim - Java bridge. <!-- - [rnim](https://github.com/SciNim/rnim) - A bridge between R and Nim. Currently this is a barely working prototype. --> ### Build Systems / Package Management - [ChooseNim](https://github.com/dom96/choosenim) - Installing and switching between Nim versions (à la rustup, pyenv). - [Nake](https://github.com/fowlmouth/nake) - Describe your Nim builds as tasks. - [Nawabs](https://github.com/Araq/nawabs) - A build system that throws away version numbering in favor of git hashes. - [Nimble](https://github.com/nim-lang/nimble) - Nimble can be used as a build system. - [nimph](https://github.com/disruptek/nimph) - Nim package hierarchy manager from the future. - [nimby](https://github.com/treeform/nimby) - A very simple and unofficial package manager for Nim. - [nifty](https://github.com/h3rald/nifty) - A decentralized pseudo package manager and script runner. - [nsis](https://github.com/nim-libs/nsis) - Nim programming language setup tool. ### Logging - [chronicles](https://github.com/status-im/nim-chronicles) - A crafty implementation of structured logging for Nim. - [morelogging](https://github.com/FedericoCeratto/nim-morelogging) - Logging library for Nim. ### Testing - [faker](https://github.com/jiro4989/faker) - A Nim package that generates fake data for you. - [balls](https://github.com/disruptek/balls) - A unittest macro to save the world, or at least your Sunday. - [einheit](https://github.com/jyapayne/einheit) - A Nim unit testing library inspired by Python's unit tests. - [asynctest](https://github.com/status-im/asynctest) - Complements the standard unittest module in Nim to allow testing of asynchronous code. - [unittest2](https://github.com/status-im/nim-unittest2) - Fork of the "unittest" Nim module focusing on parallel test execution, test-level scoping and strict exception handling. ### Fuzzing - [drchaos](https://github.com/status-im/nim-drchaos) - A powerful and easy-to-use fuzzing framework in Nim for C/C++/Obj-C targets. - [libfuzzer](https://github.com/planetis-m/libfuzzer) - LibFuzzer's interface bindings. ### Benchmarking - [golden](https://github.com/disruptek/golden) - A benchmark for compile-time and/or runtime Nim. - [timeit](https://github.com/xflywind/timeit) - Measuring execution times written by Nim. - [criterion](https://github.com/disruptek/criterion) - Statistic-driven micro-benchmark framework. - [stopwatch](https://gitlab.com/define-private-public/stopwatch) - A fork of rbmz's stopwatch that adds extra features. - [nimbench](https://github.com/ivankoster/nimbench) - A micro benchmark module for Nim. ### Command-Line Interface Automation - [cligen](https://github.com/c-blake/cligen) - Infer & generate command-line interace/option/argument parsers. - [docopt.nim](https://github.com/docopt/docopt.nim) - Command-line args parser. - [argparse](https://github.com/iffy/nim-argparse) - Argument parsing for Nim. - [clapfn](https://github.com/oliversandli/clapfn) - Argument parsing similar to Python's argparse. - [cliche](https://github.com/juancarlospaco/cliche) - AutoMagic CLI argument parsing is so cliché. - [loki](https://github.com/beshrkayali/loki) - A small library for writing line-oriented command interpreters in Nim. - [confutils](https://github.com/status-im/nim-confutils) - Simplified handling of command line options and config files ## Resources ### Books - [Nim in Action](https://book.picheta.me/) - Book in Manning's "in Action" series, teaching Nim through 3 practical projects including CLI chat apps, web apps and parsers. - [Computer Programming with Nim](https://ssalewski.de/nimprogramming.html) - A gentle introduction to the Nim programming language. - [Nim Basics](https://narimiran.github.io/nim-basics/) - Tutorial for beginners and people just starting with Nim. - [Nim Style Guide](https://status-im.github.io/nim-style-guide/) - Status style guide for the Nim language. - [Mastering Nim](https://www.amazon.com/Mastering-Nim-complete-programming-language/dp/B0B4R7B9YX) - A complete guide to the programming language. ### Blogs - [Nim Blog](http://nim-lang.org/blog.html) - Official Nim blog. - [Goran Krampe](http://goran.krampe.se/nim/) - Wrapping C, Arduino, performance, links. - [HookRace](https://hookrace.net/blog/nim/) - Blog with multiple articles on Nim. - [Rants from the Ballmer Peak](https://gradha.github.io/tags/nim.html) - Posts on Nim and other languages. - [Yuriy Glukhov's blog](https://yglukhov.github.io/) - Making and shipping a game in Nim. - [Araq's Musings](https://nim-lang.org/araq) - Blog on Nim from the creator himself. - [Nim on dev.to](https://dev.to/t/nim) - Nim blogs on `dev.to`. ### Community - [The Nim forum](http://forum.nim-lang.org/) - [The Nim IRC channel](http://webchat.freenode.net/?channels=nim) - [The Nim Gitter channel](https://gitter.im/nim-lang/Nim) - [The Nim Discord channel](https://discord.gg/ptW3Rb3) - [The Nim mailing list (forum archive)](https://www.mail-archive.com/[email protected]/) - [The Nim subreddit](http://reddit.com/r/nim) - [The Nim Telegram](https://t.me/nim_lang) - [The Nim Telegram in Spanish](https://t.me/NimArgentina) - [The Nim Matrix room](https://matrix.to/#/#nim-lang:matrix.org) ### Tutorials - [Nim Days](https://xmonader.github.io/nimdays/) - A project to document my journey with Nim with mini applications, libraries documented from A to Z and also to provide new Nim users with some extra in depth information. - [How I start](https://howistart.org/posts/nim) - Great guide going from 0 to a bf interpreter and then a bf to Nim compiler. - [Learn Nim in Y minutes](https://learnxinyminutes.com/docs/nim/) - Whirlwind tour. - [Nim by Example](https://nim-by-example.github.io) - Series of pages and examples for learning the Nim programming language. - [Nim for Python programmers](https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers) - Guide to Nim for people with experience in Python. - [Nim on Rosetta Code](https://rosettacode.org/wiki/Category:Nim) - Thousands of solutions for various tasks using Nim. - [Nim Memory](http://zevv.nl/nim-memory/) - A small tutorial explaining how Nim stores data in memory. - [Nim ARC](http://zevv.nl/nim-memory/nim-arc.html) - A friendly explanation of ARC and its implications for the programmer. - [nimNx](https://github.com/dkgitdev/nimNx) - A Nintendo Switch Homebrew example project, written in Nim. - [nimNxStatic](https://github.com/dkgitdev/nimNxStatic) - A static library example aiming to help integrate Nim code into the current Homebrew C projects for Nintendo Switch ### Videos - [Nim's Official Channel](https://www.youtube.com/channel/UCDAYn_VFt0VisL5-1a5Dk7Q/videos) - Official videos introduce the powerful and interesting part in Nim language. - [Nim for Beginners](https://www.youtube.com/user/kiloneie/playlists) - This is a video series meant to teach people programming in Nim to people who have never programmed before, or are new to Nim. - [Make a website with Nim](https://www.youtube.com/watch?v=ndzlVRWqT2E&list=PL6RpFCvmb5SGw7aJK1E4goBxpMK3NvkON) - This is a video series meant to teach people make a website with Nim using `jester`. - [Learning Nim](https://www.youtube.com/watch?v=I_Y94G37iR4&list=PLu-ydI-PCl0PqxiYXQMmLh7wjQKm5Cz-H) - Tutorial video series on learning Nim showcasing various features of the language and its libraries. - [araq twitch](https://www.twitch.tv/araq4k) - The live broadcast regarding Nim language. - [alehander42 twitch](https://www.twitch.tv/alehander42) - The live broadcast regarding Nim language. - [clyybber twitch](https://www.twitch.tv/clyybber) - The live broadcast regarding Nim language. - [d0m96 twitch](https://www.twitch.tv/d0m96) - The live broadcast regarding Nim language. - [disruptek twitch](https://www.twitch.tv/disruptek) - The live broadcast regarding Nim language. - [yardanico twitch](https://www.twitch.tv/yardanico) - The live broadcast regarding Nim language. - [zachary_carter twitch](https://www.twitch.tv/zachary_carter) - The live broadcast regarding Nim language. --- ### Footnotes *Awesome-Nim logo is based on the "Nim Crown" logo by Joseph Wecker, used with permission from the Nim project.*
3
:tropical_drink: A curated list of awesome gulp resources, plugins, and boilerplates for a better development workflow automation - http://alferov.github.io/awesome-gulp
null
4
gulp资料收集
# use-gulp #### 为什么使用gulp? 首先看一篇文章 [Gulp的目标是取代Grunt](http://www.infoq.com/cn/news/2014/02/gulp) >根据gulp的文档,它努力实现的主要特性是: > - 易于使用:采用代码优于配置策略,gulp让简单的事情继续简单,复杂的任务变得可管理。 > - 高效:通过利用node.js强大的流,不需要往磁盘写中间文件,可以更快地完成构建。 > - 高质量:gulp严格的插件指导方针,确保插件简单并且按你期望的方式工作。 > - 易于学习:通过把API降到最少,你能在很短的时间内学会gulp。构建工作就像你设想的一样:是一系列流管道。 > Gulp通过**流和代码优于配置**策略来尽量简化任务编写的工作。 别的先不说,通过代码来比较两者(gulp VS grunt) 可以参照我的代码,也可以阅读[该文章] (http://www.techug.com/gulp)。 - [Gruntfile.js](https://github.com/hjzheng/angular-cuf-nav/blob/master/Gruntfile.js) - [gulpfile.js](https://github.com/hjzheng/html2js-gulp-for-cuf/blob/master/gulpfile.js) 两者的功能基本类似,gulp是通过代码完成任务,体现了代码优于配置的原则,对程序员更加友好,另外它也可以将多个功能一次性串起来,不需要暂存在本地,体现了对流的使用,这个可以阅读[该文章](http://www.techug.com/gulp)里的例子。 另外,经常会有人问,为什么gulp比grunt快,这个可以参考这篇[文章](http://jaysoo.ca/2014/01/27/gruntjs-vs-gulpjs/) 或者我本人在segmentfault上得回答[编译同样的scss,为什么gulp的速度几乎是grunt的两倍?](http://segmentfault.com/q/1010000003951849/a-1020000003952258) #### 关于NodeJS流(stream) 因为gulp是基于流的方式工作的,所以想要进一步深入gulp,我们应该先学习NodeJS的流, 当然即使对流不熟悉,依然可以很方便的使用gulp。 - 资料 - [NodeSchool stream-adventure](https://github.com/substack/stream-adventure) - [stream-handbook](https://github.com/substack/stream-handbook) - 相关视频 - [How streams help to raise Node.js performance](https://www.youtube.com/watch?v=QgEuZ52OZtU&list=PLPlAdM3UjHKok9rS8_RTQTSLtRBThk1ni&index=2) - [Node.js streams for the utterly confused](https://www.youtube.com/watch?v=9llfAByho98&index=1&list=PLPlAdM3UjHKok9rS8_RTQTSLtRBThk1ni) #### 常用资料 - Gulp官网 http://gulpjs.com/ - Gulp中文网 http://www.gulpjs.com.cn/ - Gulp中文文档 https://github.com/lisposter/gulp-docs-zh-cn - Gulp插件网 http://gulpjs.com/plugins/ - Awesome Gulp https://github.com/alferov/awesome-gulp - StuQ-Gulp实战和原理解析 http://i5ting.github.io/stuq-gulp/ - glob用法 https://github.com/isaacs/node-glob #### gulp常用插件 - **流控制** - [event-stream](http://www.atticuswhite.com/blog/merging-gulpjs-streams/) 事件流,不是插件但很有用 - [gulp-if](https://github.com/robrich/gulp-if) 有条件的运行一个task - [gulp-clone](https://github.com/mariocasciaro/gulp-clone) Clone files in memory in a gulp stream 非常有用 - [vinyl-source-stream](https://github.com/hughsk/vinyl-source-stream) Use conventional text streams at the start of your gulp or vinyl pipelines - **AngularJS** - [gulp-ng-annotate](https://github.com/Kagami/gulp-ng-annotate) 注明依赖 for angular - [gulp-ng-html2js](https://github.com/marklagendijk/gulp-ng-html2js) html2js for angular - [gulp-angular-extender](https://libraries.io/npm/gulp-angular-extender) 为angular module添加dependencies - [gulp-angular-templatecache](https://github.com/miickel/gulp-angular-templatecache) 将html模板缓存到$templateCache中 - **文件操作** - [gulp-clean](https://github.com/peter-vilja/gulp-clean) 删除文件和目录, 请用[del](https://github.com/sindresorhus/del)来代替它[Example](https://github.com/hjzheng/CUF_meeting_knowledge_share/tree/master/2015-11-10) - [gulp-concat](https://github.com/wearefractal/gulp-concat) 合并文件 - [gulp-rename](https://github.com/hparra/gulp-rename) 重命名文件 - [gulp-order](https://github.com/sirlantis/gulp-order) 对src中的文件按照指定顺序进行排序 - [gulp-filter](https://github.com/sindresorhus/gulp-filter) 过滤文件 非常有用 [Example](https://github.com/hjzheng/CUF_meeting_knowledge_share/blob/master/2015-11-10/gulpfile.js) - [gulp-flatten](https://github.com/armed/gulp-flatten) 当拷贝文件时,不想拷贝目录时使用 [segmentfault](http://segmentfault.com/q/1010000004266922) - **压缩** - [gulp-clean-css](https://github.com/scniro/gulp-clean-css)压缩css - [gulp-uglify](https://github.com/terinjokes/gulp-uglify) 用uglify压缩js - [gulp-imagemin](https://github.com/sindresorhus/gulp-imagemin) 压缩图片 - [gulp-htmlmin](https://github.com/jonschlinkert/gulp-htmlmin) 压缩html - [gulp-csso](https://github.com/ben-eb/gulp-csso) 优化CSS - **工具** - [gulp-load-plugins](https://github.com/jackfranklin/gulp-load-plugins) 自动导入gulp plugin - [gulp-load-utils](https://www.npmjs.com/package/gulp-load-utils) 增强版gulp-utils - [gulp-task-listing](https://github.com/OverZealous/gulp-task-listing) 快速显示gulp task列表 - [gulp-help](https://github.com/chmontgomery/gulp-help) 为task添加帮助描述 - [gulp-jsdoc3](https://github.com/mlucool/gulp-jsdoc3) 生成JS文档 - [gulp-plumber](https://github.com/floatdrop/gulp-plumber) Prevent pipe breaking caused by errors from gulp plugins [Example](https://github.com/hjzheng/CUF_meeting_knowledge_share/tree/master/2015-11-10) - [yargs](https://github.com/bcoe/yargs) 处理 process.argv - [run-sequence](https://github.com/OverZealous/run-sequence) 顺序执行 gulp task,gulp 4.0 已经支持该功能 `gulp.series(...tasks)` - [gulp-notify](https://github.com/mikaelbr/gulp-notify) gulp plugin to send messages based on Vinyl Files - [gulp-shell](https://github.com/sun-zheng-an/gulp-shell) 非常有用 - [gulp-grunt](https://github.com/gratimax/gulp-grunt) 在gulp中运行grunt task - **JS/CSS自动注入** - [gulp-usemin](https://github.com/zont/gulp-usemin) Replaces references to non-optimized scripts or stylesheets into a set of HTML files - [gulp-inject](https://github.com/klei/gulp-inject) 在HTML中自动添加style和script标签 [Example](https://github.com/hjzheng/CUF_meeting_knowledge_share/tree/master/2015-8-17/bower-dependence-inject) - [wiredep](https://github.com/taptapship/wiredep) 将bower依赖自动写到index.html中 [Example](https://github.com/hjzheng/CUF_meeting_knowledge_share/tree/master/2015-8-17/bower-dependence-inject) - [gulp-useref](https://github.com/jonkemp/gulp-useref) 功能类似与usemin [Example](https://github.com/hjzheng/CUF_meeting_knowledge_share/tree/master/2015-8-17/bower-dependence-inject) 新版本用法有变化,详见gulp-useref的README.md - **代码同步** - [browser-sync](https://github.com/BrowserSync/browser-sync) 自动同步浏览器,结合gulp.watch方法一起使用 [Example 1](https://github.com/hjzheng/CUF_meeting_knowledge_share/tree/master/2015-5-30/gulp-babel-test) [Example 2](https://github.com/hjzheng/es6-practice/blob/master/gulpfile.js) - [gulp-nodemon](https://github.com/JacksonGariety/gulp-nodemon) server端代码同步 - **Transpilation** - [gulp-babel](https://github.com/babel/gulp-babel) 将ES6代码编译成ES5 [Example](https://github.com/hjzheng/CUF_meeting_knowledge_share/tree/master/2015-5-30/gulp-babel-test) - [babelify](https://github.com/babel/babelify) Browserify transform for Babel - [gulp-traceur](https://github.com/sindresorhus/gulp-traceur) Traceur is a JavaScript.next-to-JavaScript-of-today compiler - **打包** - [gulp-browserify](https://www.npmjs.com/package/gulp-browserify) 用它和 babelify 实现ES6 module [Example](https://github.com/hjzheng/CUF_meeting_knowledge_share/tree/master/2015-5-30/gulp-es6-module) - **编译** - [gulp-less](https://github.com/plus3network/gulp-less) 处理less [Example](https://github.com/hjzheng/CUF_meeting_knowledge_share/tree/master/2015-7-23/gulp-less-bootstrap) - [gulp-sass](https://github.com/dlmanning/gulp-sass) 处理sass - **代码分析** - [gulp-jshint](https://github.com/spalger/gulp-jshint) JSHint检查 [Example](https://github.com/hjzheng/CUF_meeting_knowledge_share/tree/master/2015-11-10) - [gulp-jscs](https://github.com/jscs-dev/gulp-jscs) 检查JS代码风格 [Example](https://github.com/hjzheng/CUF_meeting_knowledge_share/tree/master/2015-11-10) - **特别推荐** - [gulp-changed](https://github.com/sindresorhus/gulp-changed) 只传输修改过的文件 - [gulp-cached](https://github.com/wearefractal/gulp-cached) 将文件先cache起来,先不进行操作 - [gulp-remember](https://github.com/ahaurw01/gulp-remember) 和gulp-cached一块使用 - [gulp-newer](https://github.com/tschaub/gulp-newer) pass through newer source files only, supports many:1 source:dest - **其他** - [webpack-stream](https://github.com/shama/webpack-stream) gulp与webpack [Example](https://github.com/hjzheng/angular-es6-practice/blob/master/gulp/scripts.js) - [gulp-autoprefixer](https://github.com/sindresorhus/gulp-autoprefixer) Prefix CSS - [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) 生成source map文件 - [gulp-rev](https://github.com/sindresorhus/gulp-rev) Static asset revisioning by appending content hash to filenames: unicorn.css → unicorn-d41d8cd98f.css - [gulp-rev-replace](https://github.com/jamesknelson/gulp-rev-replace) [Example](https://github.com/hjzheng/CUF_meeting_knowledge_share/tree/master/2015-11-10) - [gulp-iconfont](https://github.com/nfroidure/gulp-iconfont) 制作iconfont [Example](https://github.com/hjzheng/CUF_meeting_knowledge_share/tree/master/2015-7-24/gulp-test-iconfont) - [gulp-svg-symbols](https://github.com/Hiswe/gulp-svg-symbols) 制作SVG Symbols, [关于使用SVG Symbol](http://isux.tencent.com/zh-hans/16292.html) - [gulp-template](https://github.com/sindresorhus/gulp-template) 模板替换 - [gulp-dom-src](https://github.com/cgross/gulp-dom-src) 将html中的script,link等标签中的文件转成gulp stream。 - [gulp-cheerio](https://github.com/KenPowers/gulp-cheerio) Manipulate HTML and XML files with Cheerio in Gulp. - [require-dir](https://www.npmjs.com/package/require-dir) 利用它我们可以将 gulpfile.js 分成多个文件,具体用法可以参考这个[Splitting a gulpfile into multiple files](http://macr.ae/article/splitting-gulpfile-multiple-files.html) - [gulp-nodemon](https://github.com/JacksonGariety/gulp-nodemon) 强烈推荐, 监控你的node应用,并重现启动server #### gulp入门视频 - **Learning Gulp** (youtube) - [Learning Gulp #1 - Installing & Introducing Gulp ](https://www.youtube.com/watch?v=wNlEK8qrb0M) - [Learning Gulp #2 - Using Plugins & Minifying JavaScript](https://www.youtube.com/watch?v=Kh4eYdd8O4w) - [Learning Gulp #3 - Named Tasks ](https://www.youtube.com/watch?v=YBGeJnMrzzE) - [Learning Gulp #4 - Watching Files With Gulp ](https://www.youtube.com/watch?v=0luuGcoLnxM) - [Learning Gulp #5 - Compiling Sass With Gulp ](https://www.youtube.com/watch?v=cg7lwX0u-U0) - [Learning Gulp #6 - Keep Gulp Running With Plumber ](https://www.youtube.com/watch?v=rF6niaDKcxE) - [Learning Gulp #7 - Handling Errors Without Plumber ](https://www.youtube.com/watch?v=o24f4imRbxQ) - [Learning Gulp #8 - LiveReload With Gulp ](https://www.youtube.com/watch?v=r5fvdIa0ETk) - [Learning Gulp #9 - Easy Image Compression](https://www.youtube.com/watch?v=oXxMdT7T9qU) - [Learning Gulp #10 - Automatic Browser Prefixing ](https://www.youtube.com/watch?v=v259QplNDKk) - [Learning Gulp #11 - Gulp Resources & What's Next ](https://www.youtube.com/watch?v=vGCzovUFBIY) - **Get started with gulp**(youtube) - [Get started with gulp Part 1: Workflow overview and jade templates](https://www.youtube.com/watch?v=DkRoa2LooNM&index=8&list=PLhIIfyPeWUjoySSdufaqfaSLeQDmCCY3Q) - [Get started with gulp Part 2: gulp & Browserify](https://www.youtube.com/watch?v=78_iyqT-qT8&index=9&list=PLhIIfyPeWUjoySSdufaqfaSLeQDmCCY3Q) - [Get started with gulp Part 3: Uglify & environment variables](https://www.youtube.com/watch?v=gRzCAyNrPV8&index=10&list=PLhIIfyPeWUjoySSdufaqfaSLeQDmCCY3Q) - [Get started with gulp Part 4: SASS & CSS minification](https://www.youtube.com/watch?v=O_0S6Z9FIKM&index=11&list=PLhIIfyPeWUjoySSdufaqfaSLeQDmCCY3Q) - [Get started with gulp Part 5: gulp.watch for true automation](https://www.youtube.com/watch?v=nsMsFyLGjSA&list=PLhIIfyPeWUjoySSdufaqfaSLeQDmCCY3Q&index=12) - [Get started with gulp Part 6: LiveReload and web server](https://www.youtube.com/watch?v=KURMrW-HsY4&list=PLhIIfyPeWUjoySSdufaqfaSLeQDmCCY3Q&index=13) - **Gulp in Action** (慕课网) - [Gulp in Action(一)](http://www.imooc.com/video/5692) - [Gulp in Action(二)](http://www.imooc.com/video/5693) - [Gulp in Action(三)](http://www.imooc.com/video/5694) - **BGTSD** (youtube) - [BGTSD - Part 20: Gulp and Babel Basics ](https://www.youtube.com/watch?v=Mo2xqBPbnlQ) - [BGTSD - Part 21: TypeScript and Gulp Basics ](https://www.youtube.com/watch?v=5Z82cpVP_qo) - **John Papa**(付费) - [JavaScript Build Automation With Gulp.js](http://www.pluralsight.com/courses/javascript-build-automation-gulpjs) #### gulp精彩文章 - [Using GulpJS to Generate Environment Configuration Modules](http://www.atticuswhite.com/blog/angularjs-configuration-with-gulpjs/) - [Introduction to Gulp.js](http://stefanimhoff.de/2014/gulp-tutorial-1-intro-setup/) - [Merging multiple GulpJS streams into one output file](http://www.atticuswhite.com/blog/merging-gulpjs-streams/) - [Getting ES6 modules working thanks to Browserify, Babel, and Gulp](http://advantcomp.com/blog/ES6Modules/) - Gulp学习指南系列: - [Gulp学习指南之入门](http://segmentfault.com/a/1190000002768534) - [Gulp学习指南之CSS合并、压缩与MD5命名及路径替换](http://segmentfault.com/a/1190000002932998) - [6 Gulp Best Practices](http://blog.rangle.io/angular-gulp-bestpractices/?utm_source=javascriptweekly&utm_medium=email) :star: - Automate all Imports (gulp-inject, wiredep, useref and angular-file-sort) - Understand directory structure requirements - Provide distinct development and production builds (browser-sync) - Inject files with gulp-inject and wiredep ( gulp-inject and wiredep ) - Create production builds with gulp-useref (gulp-useref) - Separate Gulp tasks into multiple files ```require('require-dir')('./gulp')``` - [Gulp 范儿 -- Gulp 高级技巧](http://csspod.com/advanced-tips-for-using-gulp-js/) :star: - [Gulp 错误管理](http://csspod.com/error-management-in-gulp/) :star: - [探究Gulp的Stream](http://segmentfault.com/a/1190000003770541) :star: - [Gulp安装及配合组件构建前端开发一体化](http://www.dbpoo.com/getting-started-with-gulp/) - [Gulp入门指南](https://github.com/nimojs/gulp-book) - [Gulp入门指南 - nimojs](https://github.com/nimojs/blog/issues/19) - [Gulp入门教程](http://markpop.github.io/2014/09/17/Gulp%E5%85%A5%E9%97%A8%E6%95%99%E7%A8%8B/) - [Gulp开发教程(翻译)](http://www.w3ctech.com/topic/134) - [Gulp:任务自动管理工具 - ruanyifeng](http://javascript.ruanyifeng.com/tool/gulp.html) - [BrowserSync — 你值得拥有的前端同步测试工具](http://segmentfault.com/a/1190000003787713) - [Essential Plugins for Gulp](http://ipestov.com/essential-plugins-for-gulp/) :star: - [10 things to know about Gulp](http://engineroom.teamwork.com/10-things-to-know-about-gulp/?utm_source=javascriptweekly&utm_medium=email) :star: - [Writing a gulp plugin](https://github.com/gulpjs/gulp/blob/master/docs/writing-a-plugin/README.md) :star: - [Gulp Plugin 开发](https://segmentfault.com/a/1190000000704549) :star: - [前端 | 重构 gulpfile.js](https://segmentfault.com/a/1190000002880177) - [gulp使用经验谈](http://www.qiqiboy.com/post/61) - [Splitting a gulpfile into multiple files](http://macr.ae/article/splitting-gulpfile-multiple-files.html) :star: - [Make your Gulp modular](http://makina-corpus.com/blog/metier/2015/make-your-gulp-modular) - [gulp 传参数 实现定制化执行任务](http://yijiebuyi.com/blog/d64c5d28eb539941bf3b855d333850cc.html) 使用 `gulp.env` #### gulp和ES6 - [在gulp中使用ES6](http://segmentfault.com/a/1190000004136053) :star: - [Using ES6 with gulp](https://markgoodyear.com/2015/06/using-es6-with-gulp/) #### gulp和babelify - [Example](https://gist.github.com/hjzheng/0ff59d37aa23fbd831e081138c6f24f9) #### debug gulp task - [Debugging Gulp.js Tasks](http://www.greg5green.com/blog/debugging-gulp-js-tasks/) - [Debug command line apps like Gulp](https://github.com/s-a/iron-node/blob/master/docs/DEBUG-NODEJS-COMMANDLINE-APPS.md) #### gulp项目结构应用实例 - [gulp-AngularJS1.x-seed](https://github.com/hjzheng/gulp-AngularJS1.x-seed) :star: 自己写的一个开发环境(gulp + AngularJS1.x) - [gulp模式](https://github.com/johnpapa/gulp-patterns) - [gf-skeleton-angularjs](https://github.com/gf-rd/gf-skeleton-angularjs) - [generator-hottowel](https://github.com/johnpapa/generator-hottowel) - [generator-gulp-angular](https://github.com/swiip/generator-gulp-angular#readme) - [generator-gulper](https://github.com/leaky/generator-gulper) #### gulp常见问题 [segmentfault之gulp](http://segmentfault.com/t/gulp?type=newest) - [如何拷贝一个目录?](http://stackoverflow.com/questions/25038014/how-do-i-copy-directories-recursively-with-gulp) ```js gulp.src([ files ], { "base" : "." }) ``` #### gulp 4.0 相关 目前 gulp 4.0 还没有正式release,先推荐几篇文章让大家热热身。 - [Gulp 4.0 前瞻](http://segmentfault.com/a/1190000002528547) - [Gulp 4.0 API 文档](https://github.com/cssmagic/blog/issues/55) - [是时候升级你的gulp到4.0了](http://www.alloyteam.com/2015/07/update-your-gulp/) - [Migrating to gulp 4 by example](https://blog.wearewizards.io/migrating-to-gulp-4-by-example) 不定期更新中 ... ...
5
Curriculum for learning front-end development during #100DaysOfCode.
**Note:** this resource is old! I will be archiving this repository by the end of July 2021 as I feel that many of the recommendations here are outdated for learning front-end web development in 2021. --- <p align="center"> <img alt="#100DaysOfCode Front-End Development" src="https://i.imgur.com/dwYOP0B.jpg" /> </p> **Please support this repo by giving it a star ⭐️ at the top of the page and [follow me](https://github.com/nas5w) for more resources!** Want to learn more about frontend development? Consider: - signing up for my [free newsletter](https://buttondown.email/devtuts?100DoC) where I periodically send out digestible bits of frontend knowledge! - subscribing to my [YouTube channel](https://www.youtube.com/c/devtutsco) where I teach JavaScript, Typescript, and React. --- This is a somewhat opinionated curriculum for learning front-end development during #100DaysOfCode. As it covers a wide range of front-end development topics, it can be thought of as more of a "survey" style course rather than a deep dive into any one area. Ideally, your takeaway from completing this curriculum will be some familiarity with each topic and the ability to easily dive deeper in any area in the future when necessary. This curriculum was influenced significantly by Kamran Ahmed's [Modern Frontend Developer](https://medium.com/tech-tajawal/modern-frontend-developer-in-2018-4c2072fa2b9c) roadmap. Please check it out--it is excellent. **Note**: I know front-end development means a lot of different things to a lot of people! If you're a front-end developer and you think this guide could be improved, please let me know by raising an issue as described in the [Contributing](#contributing) section. Thank you! # Translations Thanks to some incredible contributors, this curriculum has been translated into the following languages! - [Russian русский](/ru) (translation by [@Ibochkarev](https://github.com/Ibochkarev) and [@JonikUl](https://github.com/JonikUl)) - [Chinese 中文](/chinese) (translation by [@simplefeel](https://github.com/simplefeel)) - [Portuguese Português](/portuguese) (translation by [@Zardosh](https://github.com/Zardosh)) - [Polish polski](/polish) (translation by [@mbiesiad](https://github.com/mbiesiad)) - [Malay/Indonesia](/Malay) (translation by [@asyraf-labs](https://github.com/asyraf-labs)) - [Vietnamese Tiếng Việt](/Vietnam) (translation by [@duca7](https://github.com/duca7)) - [Japanese 日本語](/japanese) (translation by [miily8310s](https://github.com/miily8310s)) - [Bangla বাংলা](/bangla) (translation by [mirajus-salehin](https://github.com/mirajus-salehin)) # :calendar: Curriculum The underlying principle of this repository is [timeboxing](https://en.wikipedia.org/wiki/Timeboxing). If you have spent any amount of time in the past trying to learn web development or a similar skill, you have likely experienced going down a rabbit hole on any one particular topic. This repository aims to assign a certain number of days to each technology and encourages you to move to the next once that number of days is up. It is anticipated that everyone is at a different level of proficiency when starting this challenge, and that's okay. Beginner and expert front-end developers alike can benefit from timeboxed practice in each of these areas. The recommended day-by-day activities are as follows: - Days 1-8: [HTML](#html) - Days 9-16: [CSS](#css) - Days 17-24: [JavaScript Basics](#javascript) - Days 25-27: [jQuery](#jquery) - Days 28-33: [Responsive Web Design](#rwd) - Days 34-36: [Accessibility](#accessibility) - Days 37-39: [Git](#git) - Days 40-44: [Node and NPM](#node) - Days 45-50: [Sass](#sass) - Days 51-54: [Bootstrap](#bootstrap) - Day 55: [BEM](#bem) - Days 57-61: [Gulp](#gulp) - Days 62-65: [Webpack](#webpack) - Day 66: [ESLint](#eslint) - Days 68-83: [React](#react) - Days 84-89: [Redux](#redux) - Days 90-94: [Jest](#jest) - Days 95-97: [TypeScript](#typescript) - Days 98-100: [NextJS](#nextjs) # :mag_right: The Details Below you can find a little information about each topic in the curriculum as well as some ideas/guidance on what to do for each. For inspiration on projects to do alongside this curriculum, see the [Project Ideas section](#project-ideas). As part of the timeboxing principle, it's okay if you don't get through all of the items in the "Learning Areas and Ideas" sections. You should instead focus on getting the most you can out of the number of days assigned to each area and then move on. <a name="html"></a> ![HTML](https://i.imgur.com/O0F5XSR.jpg) Hypertext Markup Language (HTML) is the standard markup language for creating web pages and web applications. With Cascading Style Sheets (CSS) and JavaScript, it forms a triad of cornerstone technologies for the World Wide Web. Web browsers receive HTML documents from a web server or from local storage and render the documents into multimedia web pages. HTML describes the structure of a web page semantically and originally included cues for the appearance of the document. (Source: [Wikipedia](https://en.wikipedia.org/wiki/HTML)) ### :bulb: Quick Takeaway HTML is really the foundation of web development. Even in the javascript-based frameworks, you end up writing HTML in one form or another. ### :book: Learning Areas and Ideas - Take the [Basic HTML and HTML5 section](https://learn.freecodecamp.org/) on freeCodeCamp. - HTML page structure - HTML elements - Nesting HTML elements - Semantic markup - Links / multiple pages - Images - Audio/video media - Forms and form elements - Create a multi-page website! (See [Project Ideas](#project-ideas) if you need some inspiration). <a name="css"></a> ![CSS](https://i.imgur.com/028GOR0.jpg) Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language like HTML. CSS is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript. CSS is designed to enable the separation of presentation and content, including layout, colors, and fonts. This separation can improve content accessibility, provide more flexibility and control in the specification of presentation characteristics, enable multiple web pages to share formatting by specifying the relevant CSS in a separate .css file, and reduce complexity and repetition in the structural content. (Source: [Wikipedia](https://en.wikipedia.org/wiki/Cascading_Style_Sheets)) ### :bulb: Quick Takeaway CSS is another essential component of web development. While it is mainly used to style and position HTML elements, it has become increasingly capable of more dynamic tasks (e.g., animations) that would once be handled by javascript. ### :book: Learning Areas and Ideas - Take the [Basic CSS, CSS flexbox, and CSS grid sections](https://learn.freecodecamp.org/) on freeCodeCamp. - In-line CSS - `<style>` tags - External CSS with `<link>` - Styling elements - Selectors - Floats, clearing floats - Layouts (grid, flexbox) - Fonts, custom fonts - Style the HTML page(s) you made when learning HTML! <a name="javascript"></a> ![JavaScript](https://i.imgur.com/oHdD86j.jpg) JavaScript , often abbreviated as JS, is a high-level, interpreted programming language that conforms to the ECMAScript specification. It is a language that is also characterized as dynamic, weakly typed, prototype-based and multi-paradigm. Alongside HTML and CSS, JavaScript is one of the three core technologies of the World Wide Web. JavaScript enables interactive web pages and thus is an essential part of web applications. The vast majority of websites use it, and all major web browsers have a dedicated JavaScript engine to execute it. (Source: [Wikipedia](https://en.wikipedia.org/wiki/JavaScript)) ### :bulb: Quick Takeaway JavaScript has become increasingly important in the front-end world. While it was once used mainly to make pages dynamic, it is now the foundation of many front-end frameworks. These frameworks handle a lot of the tasks that were formerly handled by the back-end (e.g., routing and displaying different views). ### :book: Learning Areas and Ideas - Take the [Basic JavaScript and ES6 sections](https://learn.freecodecamp.org/) on freeCodeCamp. - Too many language fundamentals to list here! - `<script>` tag and placement - Accessing HTML elements - The event loop, call stack, and event queue - Prototypal Inheritance - Reference vs. value - Add some dynamic elements or logic to your HTML/CSS page(s) developed earlier! <a name="jquery"></a> ![jQuery](https://i.imgur.com/m9j02Fo.jpg) jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. (Source: [jQuery.com](https://jquery.com/)) ### :bulb: Quick Takeaway After you have spent some time with plain (also called "vanilla") javascript, you may find some tasks a bit cumbersome, especially those related to accessing and manipulating HTML elements. For quite a while, jQuery was the go-to library for making these kinds of tasks easier and consistent across different browsers. Nowadays, jQuery isn't necessarily "mandatory" learning because of advancements in vanilla javascript, CSS, and newer javascript frameworks (we'll look at frameworks later). Still, it would be beneficial to take a little time to learn some jQuery and apply it to a small project. ### :book: Learning Areas and Ideas - Take the [jQuery section](https://learn.freecodecamp.org/) on freeCodeCamp. - Document ready - Selectors - Toggle classes - Animation - Add or move HTML elements - Add jQuery to your site! <a name="rwd"></a> ![Responsive Web Design](https://i.imgur.com/Bt1zWwq.jpg) Responsive web design (RWD) is an approach to web design that makes web pages render well on a variety of devices and window or screen sizes. Recent work also considers the viewer proximity as part of the viewing context as an extension for RWD. Content, design and performance are necessary across all devices to ensure usability and satisfaction. A site designed with RWD adapts the layout to the viewing environment by using fluid, proportion-based grids, flexible images, and CSS3 media queries, an extension of the @media rule. (Source: [Wikipedia](https://en.wikipedia.org/wiki/Responsive_web_design)) ### :bulb: Quick Takeaway Responsive web design is all about making web applications look and function properly on all types of device. A quick-and-dirty example would be that a website should look and function properly both in a desktop web browser and on a mobile phone browser. An understanding of responsive design is crucial for any front-end developer! ### :book: Learning Areas and Ideas - Take the [Responsive Web Design Principles section](https://learn.freecodecamp.org/) on freeCodeCamp. - Media queries, breakpoints - Responsive images - Make your website responsive! - Use Chrome DevTools to view your site on different devices/viewports. <a name="accessibility"></a> ![Accessibility](https://i.imgur.com/ayioMQw.jpg) Web accessibility is the inclusive practice of ensuring there are no barriers that prevent interaction with, or access to, websites on the World Wide Web by people with disabilities. When sites are correctly designed, developed and edited, generally all users have equal access to information and functionality. (Source: [Wikipedia](https://en.wikipedia.org/wiki/Web_accessibility)) ### :bulb: Quick Takeaway Accessibility, often written as a11y, is one of the most important topics in front-end web development, yet it seems to often get short shrift. Creating accessible web applications is not only ethically sound, but also makes a lot of business sense considering the additional audience that will be able to view your applications when they are accessible. ### :book: Learning Areas and Ideas - Take the [Applied Accessibility section](https://learn.freecodecamp.org/) on freeCodeCamp. - Read some content on [The A11Y Project](https://a11yproject.com/about) - Review their [checklist](https://a11yproject.com/checklist) - Update your site(s) for accessibility based on this checklist <a name="git"></a> ![Git](https://i.imgur.com/5QoNJqs.jpg) Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. (Source: [git-scm.com](https://git-scm.com/)) ### :bulb: Quick Takeaway Version/code control is an essential part of any web developer's toolkit. There are a number of different version control systems, but Git is by far the most prevalent at the moment. You can (and should!) use it to track your projects as you learn! ### :book: Learning Areas and Ideas - [Git Tutorial for Beginners (Video)](https://www.youtube.com/watch?v=HVsySz-h9r4) - Install git - Set up a [github](https://github.com) account - Learn the most-used git commands: - init - clone - add - commit - push - pull - merge - rebase - Add your existing projects to github! <a name="node"></a> ![Node and NPM](https://i.imgur.com/8ik2alD.jpg) Node.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser. JavaScript is used primarily for client-side scripting, in which scripts written in JavaScript are embedded in a webpage's HTML and run client-side by a JavaScript engine in the user's web browser. Node.js lets developers use JavaScript to write command line tools and for server-side scripting—running scripts server-side to produce dynamic web page content before the page is sent to the user's web browser. Consequently, Node.js represents a "JavaScript everywhere" paradigm, unifying web application development around a single programming language, rather than different languages for server side and client side scripts. (Source: [Wikipedia](https://en.wikipedia.org/wiki/Node.js)) ### :bulb: Quick Takeaway While Node.js is typically known as a back-end solution, it is used quite frequently to support front-end development. It does this in a number of ways, including things like running build tools, testing, and linting (all to be covered soon!). Node Package Manager (npm) is another great feature of Node and can be used to manage dependencies of your project (i.e., code libraries your project might rely on -- jQuery is an example!). ### :book: Learning Areas and Ideas - Research node and how it is different than the browser - Install node (npm comes with it) - Create a simple javascript file and run it with node - Use NPM to manage any dependencies in your existing project(s) (e.g., jQuery!) <a name="sass"></a> ![Sass](https://i.imgur.com/ZRedLge.jpg) Sass is an extension of CSS that adds power and elegance to the basic language. It allows you to use variables, nested rules, mixins, inline imports, and more, all with a fully CSS-compatible syntax. Sass helps keep large stylesheets well-organized, and get small stylesheets up and running quickly, particularly with the help of the Compass style library. (Source: [sass-lang.com](https://sass-lang.com/documentation/file.SASS_REFERENCE.html)) ### :bulb: Quick Takeaway Sass allows you to write CSS in a more programmatic way. If you've done some CSS, you might have noticed that you end up repeating a lot of information--for example, specifying the same color code. In Sass, you can use things like variables, loops, and nesting to reduce redundancy and increase readability. After writing your code in Sass, you can quickly and easily compile it to regular CSS. ### :book: Learning Areas and Ideas - [Install Sass](https://sass-lang.com/install) globally with npm! - [Sass Crash Course Video](https://www.youtube.com/watch?v=roywYSEPSvc) - Follow the [Learn Sass](https://sass-lang.com/guide) tutorial and/or [freeCodeCamp](https://learn.freecodecamp.org/) Sass tutorial. - Update your existing site to generate your CSS using Sass! <a name="bootstrap"></a> ![Bootstrap](https://i.imgur.com/cJ21eH2.jpg) \* Some alternatives: Foundation, Bulma, Materialize Bootstrap is a free and open-source front-end framework for developing websites and web applications. It contains HTML and CSS-based design templates for typography, forms, buttons, navigation and other interface components, as well as optional JavaScript extensions. (Source: [Wikipedia](<https://en.wikipedia.org/wiki/Bootstrap_(front-end_framework)>)) ### :bulb: Quick Takeaway There are many options for laying out, styling, and making your web application dynamic, but you'll find that starting with a framework helps you tremendously in getting a head start. Bootstrap is one such framework, but it is definitely far from the only option! I recommend getting familiar with one framework like this, but it's far more important to grasp HTML, CSS, and JavaScript fundamentals than it is to get caught up in any one framework. ### :book: Learning Areas and Ideas - Learn what Bootstrap is and why you would want to use it - [Bootstrap 4 Crash Course (Video)](https://www.youtube.com/watch?v=hnCmSXCZEpU) - Complete the Bootstrap section on [freeCodeCamp](https://learn.freecodecamp.org/) - Refactor your site using bootstrap! <a name="bem"></a> ![BEM](https://i.imgur.com/MCvMRQl.jpg) The Block, Element, Modifier methodology (commonly referred to as BEM) is a popular naming convention for classes in HTML and CSS. Developed by the team at Yandex, its goal is to help developers better understand the relationship between the HTML and CSS in a given project. (Source: [css-tricks.com](https://css-tricks.com/bem-101/)) ### :bulb: Quick Takeaway It's important to know naming and organization systems like BEM exist and why they are used. Do some research here, but at a beginner level I wouldn't recommend devoting too much time to the subject. ### :book: Learning Areas and Ideas - Read the [BEM introduction](http://getbem.com/introduction/) - [Why I Use BEM (Video)](https://www.youtube.com/watch?v=SLjHSVwXYq4) - Create a simple webpage using BEM conventions. <a name="gulp"></a> ![Gulp](https://i.imgur.com/KQrByqq.jpg) Gulp is a toolkit for automating painful or time-consuming tasks in your development workflow, so you can stop messing around and build something. (Source: [gulpjs.com](https://gulpjs.com/)) ### :bulb: Quick Takeaway In modern front-end development, you'll often find yourself needing to automate tasks like bundling, moving files, and injecting references into HTML files. Gulp is one tool that can help you do these things! ### :book: Learning Areas and Ideas - Install gulp with npm - Follow the [gulp for beginners tutorial](https://css-tricks.com/gulp-for-beginners/) on CSS-Tricks - In your website, set up gulp to: - Compile Sass for you - Put the generated CSS file in `build` subdirectory - Move your web pages to the build directory - Inject a reference to your generated CSS file into your web pages <a name="webpack"></a> ![Webpack](https://i.imgur.com/0rx82Kl.jpg) At its core, webpack is a static module bundler for modern JavaScript applications. When webpack processes your application, it internally builds a dependency graph which maps every module your project needs and generates one or more bundles. (Source: [webpack.js.org](https://webpack.js.org/concepts/)) ### :bulb: Quick Takeaway Imagine that you have a large web development project with a number of different developers working on a lot of different tasks. Rather than all working in the same files, you might want to modularize them as much as possible. Webpack helps enable this by letting your team work modularly and then, come time to build the application, Webpack will stick it all together: HTML, CSS/Sass, JavasScript, images, etc. Webpack isn't the only module bundler, but it seems to be the front-runner at the moment. ### :book: Learning Areas and Ideas - Read [webpack concepts](https://webpack.js.org/concepts/) - [What is Webpack, How does it work? (Video)](https://www.youtube.com/watch?v=GU-2T7k9NfI) - [This webpack tutorial](https://hackernoon.com/a-tale-of-webpack-4-and-how-to-finally-configure-it-in-the-right-way-4e94c8e7e5c1) <a name="eslint"></a> ![ESLint](https://i.imgur.com/CJb6ZnL.jpg) ESLint is an open source JavaScript linting utility originally created by Nicholas C. Zakas in June 2013. Code linting is a type of static analysis that is frequently used to find problematic patterns or code that doesn’t adhere to certain style guidelines. There are code linters for most programming languages, and compilers sometimes incorporate linting into the compilation process. (Source: [eslint.org](https://eslint.org/docs/about/)) ### :bulb: Quick Takeaway Linting is a fantastic tool for code quality, readability, and consistency. Using a linter will help you catch syntax and formatting mistakes before they go to production. You can run linters manually or include them in your build/deployment process. ### :book: Learning Areas and Ideas - Install eslint using npm - [How to Setup VS Code + Prettier + ESLint (Video)](https://www.youtube.com/watch?v=YIvjKId9m2c) - Lint your JavaScript <a name="react"></a> ![React](https://i.imgur.com/uLYz15W.jpg) \* Some alternatives: Vue, Angular, Ember React (also known as React.js or ReactJS) is a JavaScript library for building user interfaces. It is maintained by Facebook and a community of individual developers and companies. React can be used as a base in the development of single-page or mobile applications. Complex React applications usually require the use of additional libraries for state management, routing, and interaction with an API. (source: [Wikipedia](<https://en.wikipedia.org/wiki/React_(JavaScript_library)>)) ### :bulb: Quick Takeaway Front-end JavaScript frameworks are at the forefront of modern front-end development. One important takeaway here is that React, despite being incredibly popular, is only a library for building user interfaces whereas frameworks like Vue and Angular aim to be more full-featured. For example, if you build an application with in React that needs to route to different views, you'll need to bring in something like `react-router`. ### :book: Learning Areas and Ideas - Take the [React tutorial](https://reactjs.org/tutorial/tutorial.html) - [Learn React with Mosh](https://www.youtube.com/watch?v=Ke90Tje7VS0) - Refactor your website as a React app! - Note: `create-react-app` is a convenient tool to scaffold new React projects. <a name="redux"></a> ![Redux](https://i.imgur.com/S9H2Dbp.jpg) Redux is a predictable state container for JavaScript apps. It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test. On top of that, it provides a great developer experience, such as live code editing combined with a time traveling debugger. (Source: [redux.js.org](https://redux.js.org/introduction/getting-started)) ### :bulb: Quick Takeaway As you build bigger and bigger front-end applications, you start realizing that it's hard to maintain application state: things like the if the user is logged in, who the user is, and generally what's going on in the application. Redux is a great library that helps you maintain a single source of state on which your application can base its logic. ### :book: Learning Areas and Ideas - This [Redux video tutorial](https://www.youtube.com/watch?v=93p3LxR9xfM) - This [Redux video series](https://egghead.io/courses/getting-started-with-redux) by Dan Abramov, creator of Redux - Take note of the [Redux three principles](https://redux.js.org/introduction/three-principles) - Single source of truth - State is read-only - Changes are made with pure functions - Add Redux state management to your app! <a name="jest"></a> ![Jest](https://i.imgur.com/Cr39axw.jpg) Jest is a delightful JavaScript Testing Framework with a focus on simplicity. It works with projects using: Babel, TypeScript, Node, React, Angular, Vue and more! (Source: [jestjs.io](https://jestjs.io)) ### :bulb: Quick Takeaway It is very important to set up automated testing for your front-end projects. Setting up automated testing will allow you to make future changes with confidence--if you make changes and your tests still pass, you will be fairly comfortable you didn't break any existing functionality. There are too many testing frameworks to list; Jest is simply one of my favorties. ### :book: Learning Areas and Ideas - Learn [Jest basics](https://jestjs.io/docs/en/getting-started) - If you used `create-react-app`, [Jest is already configured](https://facebook.github.io/create-react-app/docs/running-tests). - Add tests to your application! <a name="typescript"></a> ![TypeScript](https://i.imgur.com/BZROJNs.jpg) \* Alternative: Flow TypeScript is an open-source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript, and adds optional static typing to the language. TypeScript is designed for development of large applications and transcompiles to JavaScript. As TypeScript is a superset of JavaScript, existing JavaScript programs are also valid TypeScript programs. TypeScript may be used to develop JavaScript applications for both client-side and server-side (Node.js) execution. (Source: [Wikipedia](https://en.wikipedia.org/wiki/TypeScript)) ### :bulb: Quick Takeaway JavaScript is dynamically typed. However, it is a common belief that static typing (i.e., specifying variable types, classes, interfaces ahead of time) is both clearer and reduces the likelihood of defects/bugs. Regardless of how you feel on the topic, it's important to at least get a feel for a statically-typed version of JavaScript like TypeScript. Note that TypeScript compiles down to JavaScript so it can be interpreted by browsers (i.e., browsers don't natively interpret TypeScript). ### :book: Learning Areas and Ideas - [Learn TypeScript in 5 minutes](https://medium.freecodecamp.org/learn-typescript-in-5-minutes-13eda868daeb) - [Learn TypeScript in 50 minutes (Video)](https://www.youtube.com/watch?v=WBPrJSw7yQA) - Optionally [create a React app with TypeScript](https://levelup.gitconnected.com/typescript-and-react-using-create-react-app-a-step-by-step-guide-to-setting-up-your-first-app-6deda70843a4) <a name="nextjs"></a> ![NextJS](https://i.imgur.com/YNtW38J.jpg) Next.js is a minimalistic framework for server-rendered React applications. (Source: [Next.js — React Server Side Rendering Done Right](https://hackernoon.com/next-js-react-server-side-rendering-done-right-f9700078a3b6)) ### :bulb: Quick Takeaway Now we're getting advanced! By now you've built a React (or Vue or Angular) application that does quite a bit of work in the browser. For various reasons (e.g., SEO, concerns over client performance), you might actually want your front-end application to be rendered on the server rather than the client. That's where a framework like next.js comes in. ### :book: Learning Areas and Ideas - Next.js [Getting Started](https://nextjs.org/learn/) - [Next.js Crash Course (Video)](https://www.youtube.com/watch?v=IkOVe40Sy0U) - Create a Next.js app or migrate your existing app to Next.js # But What About X? This list is supposed to give you broad exposure to the front-end ecosystem, but it's simply impossible to hit on every single topic, not to mention the myriad tools within each area! If you do think I missed something very important, please see the [Contributing](#contributing) section to see how you can help make this guide better. # Project Ideas As you progress through #100DaysOfCode, you'll want one or multiple projects to which you can apply your new knowledge. In this section, I attempt to provide a few project ideas that you can use. Alternatively, you're encouraged to come up with your own project ideas as those ideas may interest and motivate you more. - Beginner ideas: - Build a portfolio website - Intermediate/Advanced ideas: - Build a tweet analysis app (If you know back-end and API integration already) # Need Help? Generally, I have found the following resources invaluable to learning software development: - Googling the issue - [StackOverflow](http://www.stackoverflow.com) (There's a good chance your question has already been asked and will be a high-ranking result when googling). - [Mozilla MDN Web Docs](https://developer.mozilla.org/en-US/) - [freeCodeCamp](https://www.freecodecamp.org/) - Local software development Meetups! Most are very friendly to all experience levels. If you'd like my input on anything, feel free to [connect with me on Twitter](http://www.twitter.com/nas5w) and I'll do my best to try to offer some assistance. If you think there's an issue with the curriculum or have a recommendation, see the [contributing section](#contributing) below. # Contributing ## Spread the Word If you appreciate the work done here, you can contribute significantly by spreading the word about this repository, including things like: - Starring and forking this repository - Sharing this repository on social media ## Contribute to this Repository This is a work in progress and I very much appreciate any help in maintaining this knowledge base! When contributing to this repository, please first discuss the change you wish to make via issue before making a change. Otherwise, it will be very hard to understand your proposal and could potentially result in you putting in a lot of work to a change that won't get merged. Please note that everyone involved in this project is either trying to learn or trying to help--Please be nice! ## Pull Request Process 1. Create an issue outlining the proposed pull request. 2. Obtain approval from a project owner to make the proposed change. 3. Create the pull request.
6
An opinionated collection of components, hooks, and utilities for your Next.js project.
<a href="https://precedent.dev"> <img alt="Precedent – Building blocks for your Next project" src="https://precedent.dev/api/og"> <h1 align="center">Precedent</h1> </a> <p align="center"> Building blocks for your Next project </p> <p align="center"> <a href="https://twitter.com/steventey"> <img src="https://img.shields.io/twitter/follow/steventey?style=flat&label=steventey&logo=twitter&color=0bf&logoColor=fff" alt="Steven Tey Twitter follower count" /> </a> <a href="https://github.com/steven-tey/precedent"> <img src="https://img.shields.io/github/stars/steven-tey/precedent?label=steven-tey%2Fprecedent" alt="Precedent repo star count" /> </a> </p> <p align="center"> <a href="#introduction"><strong>Introduction</strong></a> · <a href="#one-click-deploy"><strong>One-click Deploy</strong></a> · <a href="#tech-stack--features"><strong>Tech Stack + Features</strong></a> · <a href="#author"><strong>Author</strong></a> </p> <br/> ## Introduction Precedent is an opinionated collection of components, hooks, and utilities for your Next.js project. ## One-click Deploy You can deploy this template to Vercel with the button below: [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fsteven-tey%2Fprecedent&project-name=precedent&repository-name=precedent&demo-title=Precedent&demo-description=An%20opinionated%20collection%20of%20components%2C%20hooks%2C%20and%20utilities%20for%20your%20Next%20project.&demo-url=https%3A%2F%2Fprecedent.dev&demo-image=https%3A%2F%2Fprecedent.dev%2Fapi%2Fog&env=DATABASE_URL,GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET,NEXTAUTH_SECRET&envDescription=How%20to%20get%20these%20env%20variables%3A&envLink=https%3A%2F%2Fgithub.com%2Fsteven-tey%2Fprecedent%2Fblob%2Fmain%2F.env.example) You can also clone & create this repo locally with the following command: ```bash npx create-next-app precedent --example "https://github.com/steven-tey/precedent" ``` ## Tech Stack + Features https://user-images.githubusercontent.com/28986134/212368288-12f41e37-aa8c-4e0a-a542-cf6d23410a65.mp4 ### Frameworks - [Next.js](https://nextjs.org/) – React framework for building performant apps with the best developer experience - [Auth.js](https://authjs.dev/) – Handle user authentication with ease with providers like Google, Twitter, GitHub, etc. - [Prisma](https://www.prisma.io/) – Typescript-first ORM for Node.js ### Platforms - [Vercel](https://vercel.com/) – Easily preview & deploy changes with git - [Railway](https://railway.app/) – Easily provision a PostgreSQL database (no login required) ### UI - [Tailwind CSS](https://tailwindcss.com/) – Utility-first CSS framework for rapid UI development - [Radix](https://www.radix-ui.com/) – Primitives like modal, popover, etc. to build a stellar user experience - [Framer Motion](https://framer.com/motion) – Motion library for React to animate components with ease - [Lucide](https://lucide.dev/) – Beautifully simple, pixel-perfect icons - [`@next/font`](https://nextjs.org/docs/basic-features/font-optimization) – Optimize custom fonts and remove external network requests for improved performance - [`@vercel/og`](https://vercel.com/docs/concepts/functions/edge-functions/og-image-generation) – Generate dynamic Open Graph images on the edge - [`react-wrap-balancer`](https://github.com/shuding/react-wrap-balancer) – Simple React component that makes titles more readable ### Hooks and Utilities - `useIntersectionObserver` –  React hook to observe when an element enters or leaves the viewport - `useLocalStorage` – Persist data in the browser's local storage - `useScroll` – React hook to observe scroll position ([example](https://github.com/steven-tey/precedent/blob/main/components/layout/index.tsx#L25)) - `nFormatter` – Format numbers with suffixes like `1.2k` or `1.2M` - `capitalize` – Capitalize the first letter of a string - `truncate` – Truncate a string to a specified length - [`use-debounce`](https://www.npmjs.com/package/use-debounce) – Debounce a function call / state update ### Code Quality - [TypeScript](https://www.typescriptlang.org/) – Static type checker for end-to-end typesafety - [Prettier](https://prettier.io/) – Opinionated code formatter for consistent code style - [ESLint](https://eslint.org/) – Pluggable linter for Next.js and TypeScript ### Miscellaneous - [Vercel Analytics](https://vercel.com/analytics) – Track unique visitors, pageviews, and more in a privacy-friendly way ## Author - Steven Tey ([@steventey](https://twitter.com/steventey))
7
:snowflake: A React-Native Android iOS Starter App/ BoilerPlate / Example with Redux, RN Router, & Jest with the Snowflake Hapi Server running locally or on RedHat OpenShift for the backend, or a Parse Server running locally or remotely on Heroku
Snowflake ![snowflake](https://cloud.githubusercontent.com/assets/1282364/19871941/447b11ea-9f85-11e6-81d6-cb4b70faea6f.png) ================================== A React-Native starter mobile app, or maybe just an example, or maybe a boilerplate (you decide) for iOS and Android with a single code base, with 2 backends to chose from: a Hapi or Parse Server solution- [Demo](#screens) [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/c072e4c80b2e477591170553b149772b)](https://www.codacy.com/app/bartonhammond/snowflake?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=bartonhammond/snowflake&amp;utm_campaign=Badge_Grade) [![Join the chat at https://gitter.im/bartonhammond/snowflake](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bartonhammond/snowflake?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/bartonhammond/snowflake/blob/master/LICENSE) [![React Native](https://img.shields.io/badge/react%20native-0.41.2-brightgreen.svg)](https://github.com/facebook/react-native) ## Installation * [Install React-Native](https://facebook.github.io/react-native/docs/getting-started.html#content) ### Install Snowflake * Clone snowflake: `git clone https://github.com/bartonhammond/snowflake.git` * install dependencies ``` cd snowflake npm install ``` ### Using Snowflake Hapi Server #### Use the local or remote Snowflake Hapi Server To make things easy for you, the `config.example.js` has been initialized to use the remote **Snowflake Hapi Server** which is running on **Redhat OpenShift**. This **Snowflake Hapi Server** is Open Source. It can run either locally or on **RedHat OpenShift**. For your convince a server is running at: [https://snowflakeserver-bartonhammond.rhcloud.com](https://snowflakeserver-bartonhammond.rhcloud.com/) Please refer to [https://github.com/bartonhammond/snowflake-hapi-openshift](https://github.com/bartonhammond/snowflake-hapi-openshift) for more information about the code and instructions for installation and setup of the server. #### The following commands are for the client * Copy the ```src/lib/config.example.js``` to ```src/lib/config.js```. * **Note**: the `.gitignore` includes `config.js` from being committed to GitHub * **Note**: you must select either `hapiLocal` or `hapiRemote` for the ```backend``` as shown below with `hapiRemote` set as the default. ``` backend: { hapiLocal: false, hapiRemote: true, parseLocal: false, parseRemote: false }, ``` * To run Hapi locally, follow the instructions at [https://github.com/bartonhammond/snowflake-hapi-openshift](https://github.com/bartonhammond/snowflake-hapi-openshift). You will have to install **MongoDB** and **Redis**. * **Note**: The default is to run remotely on the **RedHat OpenShift Snowflake Server** so there is nothing more to do if you want to use it! In that case, just use the `config.js` as is. * If you want to install and run the **Snowflake Hapi Server** locally, then update the ```src/lib/config.js``` file as shown below. * **Note**: use the ip from the `ifconfig` command for the `local`. This ip matches the **Snowflake Hapi Server** setup. * An example of the `url` is shown below assuming the `ifconfig` shows the local ip to be `192.168.0.5` * **Note**: You don't have to provide the `local.url` value if you are using the `remote` ``` HAPI: { local: { url: 'http://192.168.0.5:5000' }, remote: { url: 'https://snowflakeserver-bartonhammond.rhcloud.com/' } } ``` ### Using Parse Server This **Snowflake Parse Heroku Server** is Open Source. It can run either locally or on **Heroku**. For your convince a server is running at: [https://snowflake-parse.herokuapp.com/parse](https://snowflake-parse.herokuapp.com/parse) Please refer to [https://github.com/bartonhammond/snowflake-parse-heroku](https://github.com/bartonhammond/snowflake-parse-heroku) for more information about the code and instructions for installation and setup of the server. #### The following instructions are for the client * Copy the ```src/lib/config.example.js``` to ```src/lib/config.js```. * **Note**: the `.gitignore` includes `config.js` from being committed to GitHub * Set `parseLocal` to true if you are running a local instance of parse-server * Otherwise, set `parseRemote` to true to indicate your parse server instance is hosted in the cloud ``` backend: { hapiLocal: false, hapiRemote: false, parseLocal: true, parseRemote: false }, ``` * To setup parse-server, follow the instructions at https://github.com/ParsePlatform/parse-server-example * Set the `local.url` value if you are running parse-server `local` * Set the `remote.url` value if you are running parse-server `remote` ``` PARSE: { appId: 'snowflake', // match APP_ID in parse-server's index.js local: { url: 'http://localhost:1337/parse' // match SERVER_URL in parse-server's index.js }, remote: { url: 'https://enter_your_snowflake_host.com' // match SERVER_URL in parse-server's index.js } } ``` ### To run: * For iOS, from the command line, run via command: ```react-native run-ios``` or open XCode and load project, Run ```Product -> Run (⌘+R)``` * For Android, from the command line, run via the command: ```react-native run-android``` assuming you have an emulator or device running and attached * To run Jest, ```npm test``` * To debug Jest unit cases, install [node_inspector](https://github.com/node-inspector/node-inspector) and run ```npm run test-chrome``` * Enjoy! ---------- ------------ ## Notes Code is written to [JS Standard](https://github.com/feross/standard) and validated with [Eslint](http://eslint.org/). To setup your favorite editor using the Eslint configuration, see [Editors](http://eslint.org/docs/user-guide/integrations#editors) Navigation is handled with [React Native Router Flux](https://github.com/aksonov/react-native-router-flux). Multiple scenes support **Login, Register, and Reset Password**. Once successfully logged in, there are 3 more scenes: **Logout, Subview, and Profile**. A user can **change** their **Email Address** and **User Name** once they are logged in using the **Profile** form. The icons used throughout the app are from [React Native Vector Icons](https://github.com/oblador/react-native-vector-icons), namely using **FontAwesome** **Form building** is extremely easy and consistent by using [Tcomb Form Library](https://github.com/gcanti/tcomb-form-native) by using **domain models** and writing less code. Using [Redux](https://github.com/reactjs/react-redux) and [Immutable](https://facebook.github.io/immutable-js/), the state of the application is **testable** with [Jest](https://facebook.github.io/jest/), which includes [Snapshot tests](http://facebook.github.io/jest/blog/2016/07/27/jest-14.html) currently with 85 tests and ~90% coverage!!! To ease the pain of Redux Action definitions, Snowflake uses [Key Mirror](https://github.com/STRML/keyMirror). Using the [Validate.JS](https://validatejs.org/) Library, all **user input is validated**. Appropriate messages are displayed to the user guiding them in the input requirements. Once a user is logged in, their **Session State is stored** in [AsyncStorage](https://github.com/jasonmerino/react-native-simple-store) so that subsequent usage does not require logging in again. Snowflake supports **multiple languages** using [I18n](https://github.com/AlexanderZaytsev/react-native-i18n) with English, French and Spanish. Snowflake supports **Hot Reloading** of its state. Snowflake uses CI with [Bitrise.io]( https://www.bitrise.io) and has **extensive docs and 45+ min of video** demonstating implementation. Snowflake has a **choice of servers**, either * **Hapi Server** that runs on **RedHat Openshift** and **locally**. See [https://github.com/bartonhammond/snowflake-hapi-openshift](https://github.com/bartonhammond/snowflake-hapi-openshift) for more information about the OpenShift Hapi server. The setup instructions below describe how to select the server you desire. * **Parse Server** that runs **remotely** or **locally** See [https://github.com/ParsePlatform/parse-server-example](https://github.com/ParsePlatform/parse-server-example) for more information. --------------- # Content - [Editor Configuration](#editor-configuration) - [Screens](#screens) - [Summary](#summary) - [Quotes](#quotes) - [Technologies](#technologies) - [Continuous Integration](#continuous-integration) - [Redux State Management](#redux-state-management) - [Hot Reloading](#hot-reloading) - [FAQ](#faq) - [Source documentation](http://bartonhammond.github.io/snowflake/snowflake.js.html) ---------- ## Editor Configuration **Atom** ```bash apm install editorconfig es6-javascript javascript-snippets linter linter-eslint language-babel ``` **Sublime** * https://github.com/sindresorhus/editorconfig-sublime#readme * https://github.com/SublimeLinter/SublimeLinter3 * https://github.com/roadhump/SublimeLinter-eslint * https://github.com/babel/babel-sublime **Others** * [Editorconfig](http://editorconfig.org/#download) * [ESLint](http://eslint.org/docs/user-guide/integrations#editors) * Babel Syntax Plugin ## Screens | Platform| Register | Login | Profile | | :------:| :-------: | :----: | :---: | | iOS| ![iOS Profile](https://cloud.githubusercontent.com/assets/1282364/11598478/b2b1b5e6-9a87-11e5-8be9-37cbfa478a71.gif) | ![iOS Login](https://cloud.githubusercontent.com/assets/1282364/11598580/6d360f02-9a88-11e5-836b-4171f789a41d.gif)| ![iOS Register](https://cloud.githubusercontent.com/assets/1282364/11598582/6d392750-9a88-11e5-9839-05127dfba96b.gif) | | Android |![Android Register](https://cloud.githubusercontent.com/assets/1282364/11598579/6d3487b8-9a88-11e5-9e95-260283a6951e.gif) | ![Android Login](https://cloud.githubusercontent.com/assets/1282364/11598577/6d2f140e-9a88-11e5-8cd4-1ba8c9cbc603.gif) | ![Android Profile](https://cloud.githubusercontent.com/assets/1282364/11598578/6d314ee0-9a88-11e5-9a6c-512a313535ee.gif) | ---------- ## Summary 1. The application runs on **both iOS and Android** with a **single code** base 1. A User can **Register, Login, Logout, Reset their Password** and modify their **Profile** 1. The Forms display messages for **help and field validation**. 1. The Forms are **protected** when fetching. 1. The Forms display **spinner** when fetching. 1. Form submission **errors are displayed** (see above Login) 1. **All state changes*** are actions to the Redux store. 1. The backend is provided by either a Hapi server or Parse server using the **Rest API** 1. **Every action** performed by the UI interfaces with the **Redux actions** and subsequently to the Redux Store. This **reduces the complexity** of the JSX Components **tremendously**and makes them easily testable. 1. **Jest Unit Tests cover ~90%** of the application statements. 1. Demonstrates how to **setup React-Native to perform Jest testing** with Mock modules 1. Includes ability to **debug Jest unit tests** with Chrome 1. Instructions and videos for **continuous integration with Bitrise.io** ---------- ## Quotes Some quotes from users of **Snowflake** **Open Source Mag: Learn best of React Native with these open source projects**: [http://opensourceforu.com/2016/05/learn-best-of-react-native-with-these-open-source-projects/](http://opensourceforu.com/2016/05/learn-best-of-react-native-with-these-open-source-projects/) **ICICletech Blog: Mobile App Development With 8 Awesome React-Native Starter Kits**: We have listed some of our favorite starter kits and boilerplates to get started quickly. [https://www.icicletech.com/blog/react-native-starter-kits](https://www.icicletech.com/blog/react-native-starter-kits) **Infinite.Red: Ignite Your Mobile Development:** > awesome releases as Barton Hammond’s snowflake. [https://shift.infinite.red/ignite-your-mobile-development-32417590ed3e#.pz7u3djtm](https://shift.infinite.red/ignite-your-mobile-development-32417590ed3e#.pz7u3djtm) **AdtMag: New Community Projects for React Native: Deco IDE and Pepperoni Boilerplate** [https://adtmag.com/articles/2016/05/26/react-native-projects.aspx](https://adtmag.com/articles/2016/05/26/react-native-projects.aspx) Snowflake mentioned **Pepperoni App Kit** (see [Credits](https://github.com/futurice/pepperoni-app-kit#credits)) >This project was initially motivated by Snowflake....you should check it out to see if it's a good fit for your app. **Viktor** >Just saw the tweets, still watching the vids. It's awesome!! It's really really high quality, I'm truly amazed **John** >project is awesome, thank you for providing it! **Eric**: > I've been going through snowflake and love what you have done! **Nikos**: > wow new videos, nice **Josh** >thanks for the thorough videos! **Patrick** > just wanna snowflake is awesome **Justin** >Congrats - the project is super helpful **Stephen** >Thanks so much for this amazing foundation! **Jim** >Neat project ---------- ## Technologies *The following are brief descriptions of the technologies used* ### [React-Native](https://facebook.github.io/react-native/) *React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React.* What more can I say? It's a fantastic leap forward in providing the ability to write native applications with Javascript that target both iOS and Android. This application provides one code base that works on both platforms. It demonstrates Form interactions, Navigation, and use of many other components. ### [Jest](https://facebook.github.io/jest/) *85 Unit tests that cover plain objects and JSX components* The de-facto standard for React/Native testing. This app demonstrates how to mock **ReactNative, node_modules, classes** and to properly **test JSX components** by programmatically changing the props, and throughly **test the applications data state and the actions** in conjunction with Redux. ![Jest Coverage Analysis](https://cloud.githubusercontent.com/assets/1282364/17187737/19524234-5400-11e6-8350-53e653a4c1f6.png) ### [Redux](http://redux.js.org/) *Redux is a predictable state container for JavaScript apps. It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test.* Before Redux, application state was managed by all the various components in the app. Now, the state is managed in a **predictable and consistent manner** and it can be **tested with Jest** and best of all, it is **independent** of the UI. This is a major advancement in application design! ### [Hapi](http://hapijs.com/) For me, Hapi provided a clear way for defining APIs and managing things clearly. Some folks like Express, I've used Express myself, and I wanted to try Hapi. I'm very satisfied with Hapi. As you may or may not know, WalMart Labs produced Hapi and they've used it in their business. One of the needs of any application is server side processing. With the ability to run Hapi locally or on OpenShift, I'm able to write my server logic and test it locally. When I'm "happy" I can push the code to OpenShift. The same code runs in both environments. ### [Parse Server](https://github.com/ParsePlatform/parse-server) As an alternative to Hapi, Snowflake also supports Parse Server. Parse Server is an open source version of the Parse backend that can be deployed to any infrastructure that can run Node.js. Parse Server works with the Express web application framework. You can test it locally and push changes to your parse remote server when you are ready. ### [OpenShift](https://www.openshift.com/) I chose OpenShift because I could get a reasonable performing application for free. The Snowflake server ([https://github.com/bartonhammond/snowflake-hapi-openshift](https://github.com/bartonhammond/snowflake-hapi-openshift) uses 3 gears with MongoDB and Redis. ### [TComb](https://github.com/gcanti/tcomb-form-native) *A structured model based approach to declarative forms* *With this library, you **simplify form processing** incredibly! Write a lot **less code**, get **usability** and **accessibility for free** (automatic labels, inline validation, etc) and no need to update forms when domain model changes. This application **demonstrates how to test these forms** also! ### [Validate.js](http://validatejs.org/) *Validate.js provides a declarative way of validating javascript objects.* Using Validate.js for the Form processing was a breeze! And with the ability to test the validations to the Redux state was very easy! --------------- ## Continuous Integration CI proves to the developer that everything required to build and test the application is well defined and repeatable. Without CI, one would not know, for a fact, that all the required tools and assests are available for everyone to build with. CI gives us developers some "peace of mind" that our build process is repeatable. The following videos will walk you through setting up CI with BitRise.io - [Introduction](#introduction) - [Bitrise Overview](#bitrise-overview) - [iOS XCode Modifications](#ios-xcode-modifications) - [XCode Certs Provision Profiles App Id](#xcode-certs-provision-profiles-app-id) - [Create iOS App](#create-ios-app) - [iOS install](#ios-install) - [Android Setup](#android-setup) - [Addendum #1](#addendum-#1) - [Things not addressed](#things-not-addressed) ---------- ##### Introduction * **Video 1/7**: [https://youtu.be/EYafslJvXz8](https://youtu.be/EYafslJvXz8) <a href="http://www.youtube.com/watch?feature=player_embedded&v=EYafslJvXz8" target="_blank"> <img src="http://img.youtube.com/vi/EYafslJvXz8/0.jpg" alt="Introduction" width="240" height="180" border="10" /> </a> * Snowflake is a *starter app* so all tutorials are basic in nature * There are a bizzilion ways of doing any of this - I'm showing one * There's a number of CI sites, I chose Bitrise.io * There's a general understanding of why to us a CI * The build will be done on Bitrise.io - not locally * The **only** goal is to get the build to run on Bitrise.io * You can **still** run applications locally with simulators ##### Bitrise Overview * **Video 2/7**: [https://youtu.be/JAHlfNUKoLg](https://youtu.be/JAHlfNUKoLg) <a href="http://www.youtube.com/watch?feature=player_embedded&v=JAHlfNUKoLg" target="_blank"> <img src="http://img.youtube.com/vi/JAHlfNUKoLg/0.jpg" alt="Bitrise.io Overview" width="240" height="180" border="10" /> </a> * Introduction to Bitrise.io [https://www.bitrise.io/](https://www.bitrise.io/) * Overview of what it does for us * Overview of the two WorkFlows * iOS * Android ##### iOS XCode Modifications * **Video 3/7**: [https://youtu.be/3y72adWNRSU](https://youtu.be/3y72adWNRSU) <a href="http://www.youtube.com/watch?feature=player_embedded&v=3y72adWNRSU" target="_blank"> <img src="http://img.youtube.com/vi/3y72adWNRSU/0.jpg" alt="iOS XCode Modifications" width="240" height="180" border="10" /> </a> * XCode * Icons - Asset Catalog Creator Free - see App Store * Bundler ID * [ https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/ConfiguringYourApp/ConfiguringYourApp.html](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/ConfiguringYourApp/ConfiguringYourApp.html) * AppDelegate.m * Versioning * [https://developer.apple.com/library/ios/qa/qa1827/_index.html](https://developer.apple.com/library/ios/qa/qa1827/_index.html) * Automatic Certificate & Development ##### XCode Certs Provision Profiles App Id * **Video 4/7**: [https://youtu.be/zJXoHIaJg7Y](https://youtu.be/zJXoHIaJg7Y) <a href="http://www.youtube.com/watch?feature=player_embedded&v=zJXoHIaJg7Y" target="_blank"> <img src="http://img.youtube.com/vi/zJXoHIaJg7Y/0.jpg" alt="XCode Certs Provision Profiles" width="240" height="180" border="10" /> </a> * see [https://developer.apple.com/library/ios/qa/qa1814/_index.html](https://developer.apple.com/library/ios/qa/qa1814/_index.html) * App Development Center * Remove all Certs, App Ids, and Profiles * Generating Certificates and Provision Profile * Update XCode appDelegate.m w/ ifconfig value * Xcode -> Run with device attached * Select option for Xcode to fix signing ##### Create iOS App * **Video 5/7**: [Bitrise, YML, Profile, P12](https://youtu.be/olfpwEjVlZ4) <a href="http://www.youtube.com/watch?feature=player_embedded&v=olfpwEjVlZ4" target="_blank"> <img src="http://img.youtube.com/vi/olfpwEjVlZ4/0.jpg" alt="Create iOS App" width="240" height="180" border="10" /> </a> * Login/Register Bitrise.io * Dashboard * Add App * Authenticate GitHub * Select repository, branch * Import YML * Download Certifications * Update KeyChain * Save .p12 * Download Provision * Load .p12 and provision to Bitrise.io * Setup Secret and Env Vars * Build ##### iOS install * **Video 6/7**: [https://youtu.be/nQWXJI0ncns](https://youtu.be/nQWXJI0ncns) <a href="http://www.youtube.com/watch?feature=player_embedded&v=nQWXJI0ncns" target="_blank"> <img src="http://img.youtube.com/vi/nQWXJI0ncns/0.jpg" alt="iOS install from email" width="240" height="180" border="10" /> </a> * From device, open email app * Open **letsconnect** * Follow instructions to load in Safarie * Follow prompts and enjoy! ##### Android Setup * **Video 7/7**: [Android YML, Setup](https://youtu.be/o4RQZodbzIU) <a href="http://www.youtube.com/watch?feature=player_embedded&v=o4RQZodbzIU" target="_blank"> <img src="http://img.youtube.com/vi/o4RQZodbzIU/0.jpg" alt="Android Setup" width="240" height="180" border="10" /> </a> * Settings -> Docker Image * Secret Variables * App/build.gradle * Setup Secret and Env Vars * Import YML * Run build ##### Addendum #1 * **Video**: [XCode Edge Stack, WorkFlow](https://youtu.be/mP5D2MQboxw) <a href="http://www.youtube.com/watch?feature=player_embedded&v=mP5D2MQboxw" target="_blank"> <img src="http://img.youtube.com/vi/mP5D2MQboxw/1.jpg" alt="XCode Edge Stack" width="240" height="180" border="10" /> </a> * "XCode Edge Stack" for iOS * New React-Native steps for Install & Bundle * Upgraded Step versions * GitHub branch triggers ##### Things not addressed * Submission to any store * Working with other CIs * Complex setups for either iOS or Android * Debugging any failures * Shiny new things * No local builds with Bitrise CLI * No local builds with Fastlane * No tutorial on all the features of Fastlane --------------- ## Redux State Management This section explains a little about what I've learned with Redux and the management of application state. ### Without Redux ![Alt text](https://g.gravizo.com/source/custom_mark10?https%3A%2F%2Fraw.githubusercontent.com%2Fbartonhammond%2Fsnowflake%2Fmaster%2FREADME.md) <details> <summary></summary> custom_mark10 digraph G { aize ="4,4"; login [shape=box]; login -> validate [style=bold,label="1"]; login -> restful [style=bold,label="2"]; restful -> parse [style=bold,label="3"]; login -> router [style=bold,label="4"]; router-> new_page [style=bold,label="5"]; } custom_mark10 </details> A typical app, at least those I've written before, have logic and state scattered all through out. Frameworks help to organize but typically the developer has to know how to "stitch" it together by remembering to update certain state at certain times. In the above diagram, the Login component is responsible for calling the Validate and making sure the rules are applied and errors are displayed. Then it has to have logic that confirms everything is in the right state, and pass that data to a Restul API to interact, in this case, with Parse. When that activity is complete the Router has to be informed and a new_page can be displayed. This makes testing hard as the logic is partially contained in the Login component itself and the sequence of those events are encapsulated there too! ### With Redux ![Alt text](https://g.gravizo.com/source/custom_mark11?https%3A%2F%2Fraw.githubusercontent.com%2Fbartonhammond%2Fsnowflake%2Fmaster%2FREADME.md) <details> <summary></summary> custom_mark11 digraph G { aize ="4,4"; login [shape=box]; login -> Action[style=bold,label="1"]; Action -> Reducer [style=bold,label="2"]; Reducer -> login [style=bold,label="3"]; login -> Action [style=bold,label="4"]; Action -> restful [style=bold,label="5"]; restful -> parse [style=bold,label="6"]; Action -> Reducer [style=bold,label="7"]; Reducer -> new_page [style=bold,label="8"]; } custom_mark11 </details> What the above diagram depicts is that the logic for login is contained in the Actions and Reducer and can be tested in isolation from the UI. This also makes the UI Component Login much simpler to write as it just renders content based on props that are provided. The props are actually the Reducer Store. So what is happening in this diagram? Where's the Validation? That would be in step 1. When the user enters characters on the form, they are sent to an action. The action packages them up and sends them to the Reducer. The reducer looks at what Type the Action is and performs the operation, in this case, Validate the parameters. How does Login respond? Well, it recieves the updated Props - the properties which are the store. It then renders it's output based on those properties. Just straight forward logic - nothing more then checking the properties and display approptiately. At no time does the Login component change any property state. The responsibility of changing state belongs to the Reducer. Every time an Action is called, that Action interacts w/ the Reducer. The Reducer does state changes on the State or Store model. Let's look at a concrete example, Resetting a Password. Now the UI is pretty simple, provide a Text Input for the email entry and a Button to click. Let's further assume that the email has been validated and the user clicks the "Reset Password" button. All that Login does is call an Action function called ```resetPassword``` passing the email value. So don't get too overwhelmed with the following code. You can think of the ```dispatch``` calls as meerly as a messaging system. Each ```dispatch``` call invokes a function - it just calls a function in a Promise chain. I want to now look at one specific Action and trace it's path. That action is the ```dispatch(resetPasswordRequest());``` call. That call signals that the "**reset password request**" processing is starting. We'll look at that next and how it trickles all the way back to the Login ui. > Action.resetPassword ``` export function resetPassword(email) { return dispatch => { dispatch(resetPasswordRequest()); return new Parse().resetPassword({ email: email }) .then((response) => { if (response.status === 200 || response.status === 201) { dispatch(loginState()); dispatch(resetPasswordSuccess()); } else { dispatch(resetPasswordFailure(JSON.parse(response._bodyInit))); } return response; }) .then((response) => { if (response.status === 200 || response.status === 201) { dispatch(emitLoggedOut()); } }) .catch((error) => { dispatch(resetPasswordFailure(error)); }); }; } ``` The simple function returns an object with type ```RESET_PASSWORD_REQUEST```. All of the activities performed have this pattern, make a REQUEST and then either have a SUCCESS or a FAILURE. Now Redux is responsible for taking this returned Action object and passing it to the Reducer. What does the Reducer do with this Action? We'll look at that next. > Action.resetPasswordRequest ``` export function resetPasswordRequest() { return { type: RESET_PASSWORD_REQUEST }; } ``` The Reducer is a function with 2 parameters, state and action. What it does is to make modifications to the state depending upon the action. The state is any javascript object you like. This application uses Immutable.js for it's state so to guarantee the state is always immutable. Notice the ```switch``` statement - it's looking at that Action.type value - all Actions have a type value. In our case, the type is RESET_PASSWORD_REQUEST. So what's happening here. If any request type comes to the Reducer, including RESET_PASSWORD_REQUEST, we change the state by setting the ```form.isFetching``` to ```true``` and the ```form.error``` field to null. The returned new state value has these two fields set. What happens with that new state? Well Redux makes that state available in the Login component ```props```. And since the ```props``` have changed, Login needs to ```render```. Let's look at that next. > Reducer.Action.ResetPasswordRequest snippet ``` export default function authReducer(state = initialState, action) { if (!(state instanceof InitialState)) return initialState.mergeDeep(state); switch (action.type) { case SESSION_TOKEN_REQUEST: case SIGNUP_REQUEST: case LOGOUT_REQUEST: case LOGIN_REQUEST: case RESET_PASSWORD_REQUEST: let nextState = state.setIn(['form', 'isFetching'], true) .setIn(['form','error'],null); return nextState; ..... ``` So here in the ```render``` component we need to decide if a ```spinner``` should be displayed. It should display when the ```props.isFetching``` is ```true```. That's the value set above in the Reducer! All the Login ```render()``` has to do is check that property and set the UI appropriately. > Login.Header.render snippet ``` render() { let spinner = <Text> </Text>; if (this.props.isFetching) { spinner = <GiftedSpinner/>; } return ( <View style={styles.header}> <Image style={styles.mark} source={{uri: 'http://i.imgur.com/da4G0Io.png'}} /> {spinner} </View> ); } ``` Hopefully this gives you some insight into how Redux is integrated into the application. In my opinion, this is a huge step in application logic. If you'd like to read an excellent tutorial on Redux I can't recommend this one enough: [http://teropa.info/blog/2015/09/10/full-stack-redux-tutorial.html](http://teropa.info/blog/2015/09/10/full-stack-redux-tutorial.html) -------------------- ## Hot Reloading This video shows Snowflake exporting and importing state from Redux. It demonstrates, with the iOS Simulator, the process of copying the state for import at a later time. After the demo, I walk through the code to clarify how I achieved this. It's assumed you have some familiarity with Redux. Hopefully it helps you gain a better understanding of what Redux provides you! <a href="http://www.youtube.com/watch?feature=player_embedded&v=b4eqQUA3O6o" target="_blank"><img src="http://img.youtube.com/vi/b4eqQUA3O6o/0.jpg" alt="Snowflake Hot Loading" width="240" height="180" border="10" /></a> ------------- ## Faq ### How do I change the Language of the App? Just use the Settings of your Device or Simulator. ### Why did you use the RestAPI instead of the (JS-sdk | ParseReact) I looked at it initially and, imo, it had too much magic. For example, I couldn't see how I was going to isolate my JSX components easily and keep all my "state" in Redux. ParseReact is right there in the middle of your JSX component which would tie me to a very particular vendor and implementation detail. If I decided to later move away from ParseReact I'd have to rewrite a lot of code and tests. Also, it had this statement > Mutations are dispatched in the manner of Flux Actions, allowing updates to be synchronized between many different components without requiring views to talk to each other I don't want to deal w/ wrapping my head around Flux Actions and have to monkey-patch or something to get Redux Actions. In a previous life, I worked with Parse JS SDK and it's based on backbone.js. So I didn't go that direction either, because, again, I didn't want to have another data model to deal with. Plus, at the time I was using it, the SDK was buggy and it was difficult to work with. With the Parse Rest API, it's simple, can be tested itself from the command line with curl, it's clear, it's succinct and it's easily replaced with something else, an example such as Mongo/Mongoose without much, if any, impact on the code base. ###### -barton hammond
8
🌟 An universal React isomorphic boilerplate for building server-side render web app.
# React Isomorphic Boilerplate An universal React isomorphic boilerplate for building server-side render web app. [![dependencies Status](https://david-dm.org/chikara-chan/react-isomorphic-boilerplate/status.svg)](https://david-dm.org/chikara-chan/react-isomorphic-boilerplate) [![devDependencies Status](https://david-dm.org/chikara-chan/react-isomorphic-boilerplate/dev-status.svg)](https://david-dm.org/chikara-chan/react-isomorphic-boilerplate?type=dev) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/chikara-chan/react-isomorphic-boilerplate/pulls) [![npm](https://img.shields.io/npm/l/express.svg)](https://github.com/chikara-chan/react-isomorphic-boilerplate/blob/master/LICENSE) ## Introduction This repository is an universal React isomorphic boilerplate for developer to quickly build a super fast and powerful web app that can be rendered both on the client and on the server using the most cutting-edge technology. Compared to others, this boilerplate has more pithily and more elegant configuration file based on environment variables, one for development, one for production. In addition, the directory structure is organized corresponding to mvc principle aim at the best practice. ## Technology Stack - [React](https://github.com/facebook/react) - [React Router](https://github.com/ReactTraining/react-router) - [Redux](https://github.com/reactjs/redux) - [Redux+](https://github.com/xgrommx/awesome-redux) - [Sass](https://github.com/sass/sass) - [PostCSS](https://github.com/postcss/postcss) - [CSS Modules](https://github.com/css-modules/css-modules) - [Koa](https://github.com/koajs/koa) - [Koa+](https://github.com/koajs) - [Webpack](https://github.com/webpack/webpack) - [Webpack+](https://webpack.js.org/loaders/) - [Babel](https://github.com/babel/babel) - [Babel+](http://babeljs.io/docs/plugins/) - [ESLint](https://github.com/eslint/eslint) - [Hot Module Replacement](https://webpack.github.io/docs/hot-module-replacement.html) - [Code Splitting](https://webpack.github.io/docs/code-splitting.html) - ~~Database~~ - ~~Test Framework~~ ## Getting Started - Require Node.js v6 or later. - `npm install` to install dependencies and devDependencies. - `npm run dev` to start up the development environment. - `npm run build` to compile and bundle the client and server files. - `npm start` to deploy the production server. ## What's included ``` react-isomorphic-boilerplate/ // root directory ├── build/ // webpack config directory │ ├── webpack.dev.config.js // config for webpack when run development bundle │ └── webpack.prod.config.js // config for webpack when run production bundle ├── client/ // client directory │ ├── about/ // `about` module │ ├── common/ // `common` module │ ├── home/ // `home` module │ ├── shared/ // shared module │ ├── explore/ // `explore` module │ ├── index.js // client entry file │ └── routes.js // client route config ├── dist/ // bundle output directory │ ├── client/ // the client side output directory │ └── server/ // the server side output directory ├── server/ // server directory │ ├── controllers/ // controllers in server │ ├── middlewares/ // custom middlewares in server │ ├── models/ // models in server │ ├── routes/ // routes in server │ ├── app.js // create koa instance in server │ ├── server.dev.js // entry file in development mode │ └── server.prod.js // entry file in production mode ├── views/ // views directory │ ├── dev/ // output files generated by tpl in development mode │ ├── prod/ // output files generated by tpl in production mode │ └── tpl // templates injected by html-webpack-plugin ├── .editorconfig // uniform the text editor behavior ├── .eslintignore // which paths should be omitted from linting ├── .eslintrc.json // specific rules for eslint ├── .gitattributes // uniform the new line perform behavior ├── .gitignore // ignore the specific files when using git ├── LICENSE // license information ├── package.json // npm entry file ├── README.md // just what you see now └── yarn.lock // lock file autogenerated by yarn ``` ## Why Isomorphic #### SEO An application that can only run in the client-side cannot serve HTML to crawlers, so it will have poor [SEO](https://en.wikipedia.org/wiki/Search_engine_optimization) by default. Web crawlers function by making a request to a web server and interpreting the result. but if the server returns a blank page, it’s not of much value. There are workarounds, but not without jumping through some hoops. #### Performance By the same token, if the server doesn’t render a full page of HTML but instead waits for client-side JavaScript to do so, users will experience a few critical seconds of blank page or loading spinner before seeing the content on the page. There are plenty of studies showing the drastic effect a slow site has on users, and thus revenue. #### Maintainability While the ideal case can lead to a nice, clean separation of concerns, inevitably some bits of application logic or view logic end up duplicated between client and server, often in different languages. Common examples are date and currency formatting, form validations, and routing logic. This makes maintenance a nightmare, especially for more complex apps. ## Problem exists yet #### [FOUC](https://www.google.com.hk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0ahUKEwimhPqTrofRAhXHkJQKHTEYCfMQFggjMAE&url=https%3a%2f%2fen%2ewikipedia%2eorg%2fwiki%2fFlash_of_unstyled_content&usg=AFQjCNGjAnNtZtjPb5oLsT9Wlf9az7hXTw) It happens when run in development mode. This is caused by deprecated using [extract-text-webpack-plugin](https://github.com/webpack/extract-text-webpack-plugin) in development for getting a seamless hmr experience.(Why deprecated? See this [Issue](https://github.com/webpack/extract-text-webpack-plugin/issues/30)) If you are not an OCD, go ahead, ignore it. #### Mismatch It happens also when run in development mode. This is caused by when you update the react component code and reload the page, the markup generated mismatches that on server render. However, once you restart the server, the checksum will be valid. So it is harmless, ignore it also. ## Links [http://www.jianshu.com/p/0ecd727107bb](http://www.jianshu.com/p/0ecd727107bb) ## License [MIT](https://github.com/chikara-chan/react-isomorphic-boilerplate/blob/master/LICENSE)
9
🗄🙅‍♀️ Deploy your next serverless JavaScript function in seconds
![logo](./logo.png) [![Greenkeeper badge](https://badges.greenkeeper.io/postlight/serverless-typescript-starter.svg)](https://greenkeeper.io/) [![CircleCI](https://circleci.com/gh/postlight/serverless-typescript-starter/tree/master.svg?style=svg)](https://circleci.com/gh/postlight/serverless-typescript-starter/tree/master) [Postlight](https://postlight.com)'s Modern Serverless Starter Kit adds a light layer on top of the Serverless framework, giving you the latest in modern JavaScript (ES6 via Webpack, TypeScript if you want it, testing with Jest, linting with ESLint, and formatting with Prettier), the ease and power of Serverless, and a few handy helpers (like functions for handling warm functions and response helpers). Once installed, you can create and deploy functions with the latest ES6 features in minutes, with linting and formatting baked in. Read more about it in [this handy introduction](https://postlight.com/trackchanges/introducing-postlights-modern-serverless-starter-kit). Note: Currently, this starter kit specifically targets AWS. ## Install ```bash # If you don't already have the serverless cli installed, do that yarn global add serverless # Use the serverless cli to install this repo serverless install --url https://github.com/postlight/serverless-typescript-starter --name <your-service-name> # cd into project and set it up cd <your-service-name> # Install dependencies yarn install ``` ## Development Creating and deploying a new function takes two steps, which you can see in action with this repo's default Hello World function (if you're already familiar with Serverless, you're probably familiar with these steps). #### 1. Add your function to `serverless.yml` In the functions section of [`./serverless.yml`](./serverless.yml), you have to add your new function like so: ```yaml functions: hello: handler: src/hello.default events: - http: path: hello method: get ``` Ignoring the scheduling event, you can see here that we're setting up a function named `hello` with a handler at `src/hello.ts` (the `.default` piece is just indicating that the function to run will be the default export from that file). The `http` event says that this function will run when an http event is triggered (on AWS, this happens via API Gateway). #### 2. Create your function This starter kit's Hello World function (which you will of course get rid of) can be found at [`./src/hello.ts`](./src/hello.ts). There you can see a basic function that's intended to work in conjunction with API Gateway (i.e., it is web-accessible). Like most Serverless functions, the `hello` function is asynchronous and accepts an event & context. (This is all basic Serverless; if you've never used it, be sure to read through [their docs](https://serverless.com/framework/docs/). --- You can develop and test your lambda functions locally in a few different ways. ### Live-reloading functions To run the hello function with the event data defined in [`fixtures/event.json`](fixtures/event.json) (with live reloading), run: ```bash yarn watch:hello ``` ### API Gateway-like local dev server To spin up a local dev server that will more closely match the API Gateway endpoint/experience: ```bash yarn serve ``` ### Test your functions with Jest Jest is installed as the testrunner. To create a test, co-locate your test with the file it's testing as `<filename>.test.ts` and then run/watch tests with: ```bash yarn test ``` ### Adding new functions/files to Webpack When you add a new function to your serverless config, you don't need to also add it as a new entry for Webpack. The `serverless-webpack` plugin allows us to follow a simple convention in our `serverless.yml` file which is uses to automatically resolve your function handlers to the appropriate file: ```yaml functions: hello: handler: src/hello.default ``` As you can see, the path to the file with the function has to explicitly say where the handler file is. (If your function weren't the default export of that file, you'd do something like: `src/hello.namedExport` instead.) ### Keep your lambda functions warm Lambda functions will go "cold" if they haven't been invoked for a certain period of time (estimates vary, and AWS doesn't offer a clear answer). From the [Serverless blog](https://serverless.com/blog/keep-your-lambdas-warm/): > Cold start happens when you execute an inactive (cold) function for the first time. It occurs while your cloud provider provisions your selected runtime container and then runs your function. This process, referred to as cold start, will increase your execution time considerably. A frequently running function won't have this problem, but you can keep your function running hot by scheduling a regular ping to your lambda function. Here's what that looks like in your `serverless.yml`: ```yaml custom: warmup: enabled: true events: - schedule: rate(5 minutes) prewarm: true concurrency: 2 ``` The above config would keep all of your deployed lambda functions running warm. The `prewarm` flag will ensure your function is warmed immediately after deploys (so you don't have to wait five minutes for the first scheduled event). And by setting the `concurrency` to `2`, we're keeping two instances warm for each deployed function. Under `custom.warmup`, you can set project-wide warmup behaviors. On the other hand, if you want to set function-specific behaviours, you should use the `warmup` key under the select functions. You can browse all the options [here](https://www.npmjs.com/package/serverless-plugin-warmup#configuration). Your handler function can then handle this event like so: ```javascript const myFunc = (event, context, callback) => { // Detect the keep-alive ping from CloudWatch and exit early. This keeps our // lambda function running hot. if (event.source === 'serverless-plugin-warmup') { // serverless-plugin-warmup is the source for Scheduled events return callback(null, 'pinged'); } // ... the rest of your function }; export default myFunc; ``` Copying and pasting the above can be tedious, so we've added a higher order function to wrap your run-warm functions. You still need to config the ping in your `serverless.yml` file; then your function should look like this: ```javascript import runWarm from './utils'; const myFunc = (event, context, callback) => { // Your function logic }; export default runWarm(myFunc); ``` ### Pruning old versions of deployed functions The Serverless framework doesn't purge previous versions of functions from AWS, so the number of previous versions can grow out of hand and eventually filling up your code storage. This starter kit includes [serverless-prune-plugin](https://github.com/claygregory/serverless-prune-plugin) which automatically prunes old versions from AWS. The config for this plugin can be found in `serverless.yml` file. The defaults are: ```yaml custom: prune: automatic: true number: 5 # Number of versions to keep ``` The above config removes all but the last five stale versions automatically after each deployment. Go [here](https://medium.com/fluidity/the-dark-side-of-aws-lambda-5c9f620b7dd2) for more on why pruning is useful. ## Environment Variables If you have environment variables stored in a `.env` file, you can reference them inside your `serverless.yml` and inside your functions. Considering you have a `NAME` variable: In a function: ```node process.env.NAME ``` In `serverless.yml`: ```yaml provider: name: ${env:NAME} runtime: nodejs12.x ``` You can check the documentation [here](https://www.npmjs.com/package/serverless-dotenv-plugin). ## Deploy Assuming you've already set up your default AWS credentials (or have set a different AWS profile via [the profile field](serverless.yml#L25)): ```bash yarn deploy ``` `yarn deploy` will deploy to "dev" environment. You can deploy to `stage` or `production` with: ```bash yarn deploy:stage # -- or -- yarn deploy:production ``` After you've deployed, the output of the deploy script will give you the API endpoint for your deployed function(s), so you should be able to test the deployed API via that URL. --- 🔬 A Labs project from your friends at [Postlight](https://postlight.com). Happy coding!

GitSum Dataset

Dataset Description

This dataset is a collection of data originally provided by the MDEGroup GitSum repository.

Citation

If you use this dataset, please cite the original repository:

@misc{MDEGroup_GitSum,
  title={GitSum},
  author={MDEGroup},
  year={2023},
  howpublished={\url{https://github.com/MDEGroup/GitSum}},
}
Downloads last month
36
Edit dataset card