Code Monkey home page Code Monkey logo

rapidoid's Introduction

Rapidoid

Rapidoid aims to be the Coolest Full-stack Web Application Framework for Java!

Super-simple. Powerful. Secure. Cool!

Teaser:

@DbEntity
@Scaffold
@CanRead(LOGGED_IN)
@CanChange({ OWNER })
@CanInsert(LOGGED_IN)
@CanDelete({ OWNER, ADMIN })
public class Task {

	public long id; // primary key

	public long version; // optimistic CC

	@Display
	@CanChange({ MODERATOR, OWNER })
	public String title;

	@Display
	@CanChange({ MODERATOR, OWNER, SHARED_WITH })
	public Priority priority = Priority.MEDIUM;

	@Optional
	@CanChange({ MODERATOR, OWNER, SHARED_WITH })
	public String description;

	public int rating;

	@Programmatic
	public final DbRef<User> owner = DB.ref(this, "^owns");

	@CanRead({ OWNER })
	public final DbSet<User> sharedWith = DB.set(this, "sharedWith");

	@Programmatic
	@CanRead({ OWNER, SHARED_WITH })
	public final DbList<Comment> comments = DB.list(this, "has");

	@Programmatic
	public final DbSet<User> likedBy = DB.set(this, "^likes");

}

Apache License v2

The software is released under the liberal Apache Public License v2, so it is free to use for both commercial and non-commercial projects.

Step-by-step introduction

A step-by-step tutorial is available at the official site: http://www.rapidoid.org/

Using with Maven

Add the following snippet to the <dependencies> section in pom.xml:

<dependency>
    <groupId>org.rapidoid</groupId>
    <artifactId>rapidoid-all</artifactId>
    <version>2.0.2</version>
</dependency>

Quick start

  • Add the rapidoid-all dependency to your Maven project (as described above).

  • Add the file App.java:

import org.rapidoid.app.Apps;

public class App {

	public String title = "Issue Management";

	public boolean full = true;

	public boolean fluid = false;

	public String theme = "1";

	public static void main(String[] args) {
		Apps.run(args);
	}

}
  • Add the file HomeScreen.java:
import org.rapidoid.app.Screen;
import org.rapidoid.db.DB;

public class HomeScreen extends Screen {

	public Object content() {
		return render("home.html", "count", DB.getAll(Issue.class).size());
	}

}
  • Add the file Issue.java:
import org.rapidoid.annotation.*;

@Scaffold
@DbEntity
public class Issue {

	public long id;

	public String title;

	public Priority priority = Priority.MEDIUM;

	@Optional
	public String description;

}
  • Add the file Priority.java:
public enum Priority {
	LOW, MEDIUM, HIGH;
}
  • Add the file NewIssueScreen.java:
import org.rapidoid.annotation.Session;
import org.rapidoid.app.Screen;
import org.rapidoid.db.DB;
import org.rapidoid.html.Tag;
import org.rapidoid.widget.FormWidget;

public class NewIssueScreen extends Screen {

	@Session
	public Issue issue = new Issue();

	public Object content() {
		Tag title = h2("Add new issue").style("margin-bottom:15px");
		FormWidget form = create(issue).buttons(SAVE, CANCEL);
		return mid6(title, form);
	}

	public void onSave() {
		DB.insert(issue);
		issue = new Issue();
	}

	public void onCancel() {
		issue = new Issue();
	}

}

Rapidoid will scan for *Screen classes on your classpath and will construct a nice and responsive GUI. It will start a fast embedded HTTP server (rapidoid-http).

REST services

  • Add the MainService.java file:
import java.util.List;
import java.util.Map;

public class MainService {

    public String index() {
        return "hi!";
    }

    public String hey(String name, int age) {
        return "Hey " + name + " (" + age + ")";
    }

    public List<String> foo(List<String> params) {
        return params;
    }

    public Map<String, Object> bar(Map<String, Object> params) {
        return params;
    }

}

Rapidoid will scan for *Service classes on your classpath and start a fast embedded HTTP server (rapidoid-http).

Contributing

  1. Fork (and then git clone https://github.com/<your-username-here>/rapidoid.git).
  2. Create a branch (git checkout -b branch_name).
  3. Commit your changes (git commit -am "Description of contribution").
  4. Push the branch (git push origin branch_name).
  5. Open a Pull Request.
  6. Thank you for your contribution! Wait for a response...

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.