Git Product home page Git Product logo

pharaoh's Introduction

Pharaoh ๐Ÿ‡

Dart codecov Pub Version popularity likes melos

Features

  • Robust routing
  • Focus on high performance
  • Super-high test coverage
  • HTTP helpers (just like ExpressJS)
  • Interoperability with Shelf Middlewares See here

Installing:

In your pubspec.yaml

dependencies:
  pharaoh: ^0.0.6 # requires Dart => ^3.0.0

Basic Usage:

import 'package:pharaoh/pharaoh.dart';

final app = Pharaoh();

void main() async {

  app.use((req, res, next) {

    /// do something here

    next();

  });

  app.get('/foo', (req, res) => res.ok("bar"));

  final guestRouter = app.router()
    ..get('/user', (req, res) => res.ok("Hello World"))
    ..post('/post', (req, res) => res.json({"mee": "moo"}))
    ..put('/put', (req, res) => res.json({"pookey": "reyrey"}));

  app.group('/guest', guestRouter);

  await app.listen(); // port => 3000
}

See the Pharaoh Examples directory for more practical use-cases.

Philosophy

Pharaoh emerges as a backend framework, inspired by the likes of ExpressJS, to empower developers in building comprehensive server-side applications using Dart. The driving force behind Pharaoh's creation is a strong belief in the potential of Dart to serve as the primary language for developing the entire architecture of a company's product. Just as the JavaScript ecosystem has evolved, Pharaoh aims to contribute to the Dart ecosystem, providing a foundation for building scalable and feature-rich server-side applications.

Contributors โœจ

The Pharaoh project welcomes all constructive contributions. Contributions take many forms, from code for bug fixes and enhancements, to additions and fixes to documentation, additional tests, triaging incoming pull requests and issues, and more!

Contributing Code To Pharaoh ๐Ÿ› 

To setup and contribute to Pharaoh, Install Melos as a global package via pub.dev;

$ dart pub global activate melos

then initialize the workspace using the command below

$ melos bootstrap

Running Tests

To run the tests, you can either run dart test in the package you're working on or use the command below to run the full test suite:

$ melos run tests

People

List of all contributors

License

MIT

pharaoh's People

Contributors

codekeyz avatar fabrice8 avatar heyonuoha avatar iametornam avatar jxstxn1 avatar mihrab34 avatar rasheedmhd avatar samtuga1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pharaoh's Issues

feat: add more tests for response methods.

I've covered most delicate parts of the framework with tests. If you're down to lend a hand, please look into writing tests for the remaining methods on Response.

Also, writing tests for Pharaoh is the best thing since cake bread. Worth all your lunch money ๐Ÿฅณ

Add Contributing .md file

Description
I noticed that the project is currently missing a CONTRIBUTING.md file, which can serve as a valuable resource for new contributors and help streamline the contribution process. I propose adding this file to provide clear guidelines on contributing to the project.

Proposed Changes:

Create a CONTRIBUTING.md file in the project root and include sections such as:

  • Introduction
  • Code of Conduct
  • How to Contribute
  • Issue Reporting
  • Pull Requests
  • Coding Guidelines
  • Testing
  • Review Process
  • Communication Channels

Additional Information
I can create a pull request for this change and can collaborate with others to ensure the content is comprehensive and accurate.

Please share your thoughts and suggestions on this proposal @codekeyz

Thank you!

feat: Add html display to get request

Description

Clearly describe what you are looking to add. The more context the better.
In express one can send HTML elements in response eg:app.get("/",(req,res)=>res.ok("

Hello World

"));

Requirements

  • Checklist of requirements to be fulfilled

Additional Context

Add any other context or screenshots about the feature request go here.

feat: Add cookies support to Pharaoh

Description

Ideally, we should have Cookies on the Request object just like in ExpressJS. You can check this library for more info regarding how to go about the implementation. -> https://expressjs.com/en/resources/middleware/cookie-parser.html

See the source code here: https://github.com/expressjs/cookie-parser/blob/master/index.js

Requirements

  • We should have req.cookies
  • We should have req.signedCookies

Additional Context

I'm not really sure about all there is to Cookies but please do your research and let's get cookies working in Pharaoh.

feat: Be able to test whole URIs

Description

I would like to have a way to define a base URI of the server in a Spookie Test.
Similar to the uri Parameter in the Request Object in shelf

Requirements

  • Add a way to add a base URI to a request in Spookie

Implement content negotiation like in ExpressJS

We should be able to do something similar this

     res.format({
       'text/plain': (res) => res.send('hey'),
 
       'text/html': (res) => res.send('<p>hey</p>'),
 
       '_':  (res)  => res.send({ message: 'hey' }),
    });

fix: unable to encode DateTime in Response class

Description

Turns out jsonEncode used in res.json cannot encode DateTime(is not serializable).

Code Snippet

import 'package:pharaoh/pharaoh.dart';

void main() {

    /// Retrieve the body from the response
      Map<String, dynamic> body = req.body;

      String username = body['username'];
      String email = body['email'];
      String password = body['password'];

      /// Create the user using [email] and [password]
      UserRecord savedUser = await auth.createUser(CreateRequest(
        displayName: username,
        email: email,
        password: password,
      ));

      return res.status(201).json(savedUser.toJson()); --> // Error is coming from here

}

Expected Behavior

Expected the jsonEncode() to handle objects that are not serializable

Additional Context
The following works

result = jsonEncode(
        data,
        toEncodable: (Object? object) => customEncoder(object),
      );

/// Custom encoder for to serialize [data]
Object? customEncoder(Object? data) {
  if (data == null) return null;
  if (data is DateTime) {
    return data.toUtc().toIso8601String();
  }
  return data;
}

I will create a pull request for this

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

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

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

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

  • D3 photo D3

    Data-Driven Documents codes.